<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>cocos2d for iPhone &#187; Topic: Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?</title>
		<link>http://www.cocos2d-iphone.org/forum/topic/3131</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 01:42:53 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.cocos2d-iphone.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.cocos2d-iphone.org/forum/rss/topic/3131" rel="self" type="application/rss+xml" />

		<item>
			<title>araker on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-73219</link>
			<pubDate>Sat, 29 Jan 2011 15:34:08 +0000</pubDate>
			<dc:creator>araker</dc:creator>
			<guid isPermaLink="false">73219@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>The one part of cocos that really benefits from this are tilemaps. If it's worthwhile for you to optimize this, depends if your bottleneck is the tiler. Check it using the  OpenGL ES instrument in release mode. </p>
<p>A simple implementation is to give static and dynamic geometry their own batch node and add a check in the textureAtlas class to see if any of the quads have changed. </p>
<p>You could go a step further and keep track of which indexes in the quad array have changed and perform a ranged/partial update. Though testing is needed to see if ranged updates really give better performance. From what I've red in most cases it's more efficient to just flush the buffer, instead updating a part of it.
</p></description>
		</item>
		<item>
			<title>Nico... on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-73198</link>
			<pubDate>Sat, 29 Jan 2011 10:44:12 +0000</pubDate>
			<dc:creator>Nico...</dc:creator>
			<guid isPermaLink="false">73198@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>araker, you say "Cocos on the other hand doesn't handle static and dynamic geometry differently".<br />
so cocos updates the VBOs at each frame, even though some coordinates don't change ?<br />
Do you think it could be worthwile to spend some time optimizing for that ?<br />
Like checking if sprites have moved or not, and marking them static (either a flag for background elements<br />
or a dynamic test that checks if things moved or not).</p>
<p>I'd like to try this, when I find some free time, but I don't know if this will have a great impact<br />
on fps...
</p></description>
		</item>
		<item>
			<title>araker on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-73186</link>
			<pubDate>Sat, 29 Jan 2011 07:38:43 +0000</pubDate>
			<dc:creator>araker</dc:creator>
			<guid isPermaLink="false">73186@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Interesting topic, I didn't know this was discussed here. </p>
<p>It is correct that the tiler benefits from a smaller vertex format. To go into more detail, on older (MBX) devices the performance will linearly increase with the reduction of the vertex size (in case you're tiler limited). Caching of vertex data (VBO's) doesn't work (a broken implementation), so the data needs to be send to GPU every frame and the amount of data quickly becomes the bottleneck.</p>
<p>Newer devices (SGX) can use VBO's to cache the vertex data for the GPU. To use this optimally sorting static and dynamic geometry is needed, so that the static geometry can be cached for the GPU. Though this means that reducing the vertex format won't have the same impact as for the MBX devices. </p>
<p>Cocos on the other hand doesn't handle static and dynamic geometry differently, so the performance in cocos will scale similarly for MBX and SGX. </p>
<p>To get back to the performance benefit, the current vertex format is 24 bytes, CJ's proposed format is 20 bytes, which will give a performance benefit around 16,67%. When I implemented this I used a smaller format with shorts for texture coordinates as well. Then the format is reduced to 16 bytes, a reduction of 33.3%, which is the performance benefit seen in the stackoverflow topic.
</p></description>
		</item>
		<item>
			<title>Tone on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-73158</link>
			<pubDate>Sat, 29 Jan 2011 03:48:58 +0000</pubDate>
			<dc:creator>Tone</dc:creator>
			<guid isPermaLink="false">73158@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey CJ,<br />
did you ever find anything out?
</p></description>
		</item>
		<item>
			<title>CJ on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-21134</link>
			<pubDate>Wed, 16 Dec 2009 17:02:59 +0000</pubDate>
			<dc:creator>CJ</dc:creator>
			<guid isPermaLink="false">21134@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I'm working on a full writeup on how to get the most performance from Cocos2D and OpenGL, but the prelim results for this aspect are... If you reduce the data size sent to openGL (by using shorts in this case to represent the positions) you reduce the utilization of the openGL Tiler. I will delve into what this means further when I post the full writeup, but the other factor to openGL performance is the Renderer, so if you happen to have a case where your utilization of the Renderer is low but your use of the Tiler is high this is a performance win for your app. (The Tiler/Renderer utilization stats can be seen by running with the OpenGLES instrument).</p>
<p>It turned out that in my game I am using like 99% of the renderer and only 15% of the tiler, so I've spent the last few days trying to optimize for this case. (And making Cocos2D run with GLshort vertex types is a bit of work at this stage, but I will post a patch later if people are interested in trying it)</p>
<p>Hope that all makes sense, I will post back here again when I have a full report.
</p></description>
		</item>
		<item>
			<title>Matt Rix on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-20874</link>
			<pubDate>Sun, 13 Dec 2009 18:32:04 +0000</pubDate>
			<dc:creator>Matt Rix</dc:creator>
			<guid isPermaLink="false">20874@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>They mentioned that at the iPhone tech talks, I meant to try it out, but forgot :)</p>
<p>Any results yet? I'm curious to see how much of an impact this has.
</p></description>
		</item>
		<item>
			<title>CJ on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-20855</link>
			<pubDate>Sun, 13 Dec 2009 07:19:24 +0000</pubDate>
			<dc:creator>CJ</dc:creator>
			<guid isPermaLink="false">20855@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I got an answer about the padding from none other than Jeff LaMarche (<a href="http://iphonedevelopment.blogspot.com/" rel="nofollow">http://iphonedevelopment.blogspot.com/</a>)</p>
<p>Basically I just do this to take care of the struct with 3 shorts in it (6bytes=24bits) to make it (8bytes = 32bits):</p>
<pre><code>typedef struct _ccVertex3S
{
    GLshort x;
    GLshort y;
    GLshort z;
    GLshort padding;
} ccVertex3S;</code></pre>
<p>Note that he also recommended using GL data types because it defines the size of a short to be 16 bits, but just a regular short could actually be dependent on the system.
</p></description>
		</item>
		<item>
			<title>CJ on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-20834</link>
			<pubDate>Sat, 12 Dec 2009 17:15:36 +0000</pubDate>
			<dc:creator>CJ</dc:creator>
			<guid isPermaLink="false">20834@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Re: the short vs. float thing I found this post on stackoverflow as well:<br />
<a href="http://stackoverflow.com/questions/1287811/what-does-the-tiler-utilization-statistic-mean-in-the-iphone-opengl-es-instrument" rel="nofollow">http://stackoverflow.com/questions/1287811/what-does-the-tiler-utilization-statistic-mean-in-the-iphone-opengl-es-instrument</a></p>
<p>He claims to get 30% increase in performance by making the change.</p>
<p>But I'm hoping someone can help me with this bit... padding to a 32bit boundary as described in that link. Practically, what is involved in achieving that?</p>
<p>In preparation for testing all this, I made some new struct types:<br />
<pre><code>typedef struct _ccVertex3S
{
	short x;
	short y;
	short z;
} ccVertex3S;

typedef struct _ccV3S_C4B_T2F
{
	//! vertices (3S)
	ccVertex3S		vertices;			// 6 bytes
	//	char __padding__[4];

	//! colors (4B)
	ccColor4B		colors;				// 4 bytes
	//	char __padding2__[4];

	// tex coords (2F)
	ccTex2F			texCoords;			// 8 bytes
} ccV3S_C4B_T2F;

typedef struct _ccV3S_C4B_T2F_Quad
{
	//! top left
	ccV3S_C4B_T2F	tl;
	//! bottom left
	ccV3S_C4B_T2F	bl;
	//! top right
	ccV3S_C4B_T2F	tr;
	//! bottom right
	ccV3S_C4B_T2F	br;
} ccV3S_C4B_T2F_Quad;</code></pre></description>
		</item>
		<item>
			<title>CJ on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-20762</link>
			<pubDate>Fri, 11 Dec 2009 16:29:32 +0000</pubDate>
			<dc:creator>CJ</dc:creator>
			<guid isPermaLink="false">20762@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Great, thanks Riq. Will do.
</p></description>
		</item>
		<item>
			<title>riq on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-20758</link>
			<pubDate>Fri, 11 Dec 2009 16:11:08 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">20758@http://www.cocos2d-iphone.org/forum/</guid>
			<description><blockquote><p>
1. Batch Geometry<br />
2. Texture Atlases<br />
3. Interleaved Arrays<br />
4. Indexed triangles<br />
5. Floats vs shorts (turns out shorts are good to feed into openGL)
</p></blockquote>
<p>cocos2d uses:<br />
 1,2,3,4 but not 5.</p>
<p>But if you want to make some performance tests with 5, please, post your results here.
</p></description>
		</item>
		<item>
			<title>CJ on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-20757</link>
			<pubDate>Fri, 11 Dec 2009 16:07:38 +0000</pubDate>
			<dc:creator>CJ</dc:creator>
			<guid isPermaLink="false">20757@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hmm. ok. +1 bump for Riq being back :)
</p></description>
		</item>
		<item>
			<title>Codemattic on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-20366</link>
			<pubDate>Sun, 06 Dec 2009 22:30:22 +0000</pubDate>
			<dc:creator>Codemattic</dc:creator>
			<guid isPermaLink="false">20366@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Bad time to bump since Riq is away! It looks like good advice on optimizing though.
</p></description>
		</item>
		<item>
			<title>CJ on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-20338</link>
			<pubDate>Sun, 06 Dec 2009 04:59:16 +0000</pubDate>
			<dc:creator>CJ</dc:creator>
			<guid isPermaLink="false">20338@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>+1 week. Maybe no one saw this thread. Bump.
</p></description>
		</item>
		<item>
			<title>CJ on "Drawing using interleaved array of x,y,uvx,uvy,color for performance boost?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3131#post-19299</link>
			<pubDate>Mon, 23 Nov 2009 14:56:38 +0000</pubDate>
			<dc:creator>CJ</dc:creator>
			<guid isPermaLink="false">19299@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I was listening to this podcast from Stanford's CS course which had a developer from NGMoco talking about performance optimization with OpenGL for iPhone. Here's a link which includes a demo project and the presentation slides: (you can also search itunes-U for the audio) <a href="http://gamemakers.ngmoco.com/post/111712416/stanford-university-and-apple-were-kind-enough-to" rel="nofollow">http://gamemakers.ngmoco.com/post/111712416/stanford-university-and-apple-were-kind-enough-to</a></p>
<p>His example is a particle system that he optimizes by doing the following:<br />
1. Batch Geometry<br />
2. Texture Atlases<br />
3. Interleaved Arrays<br />
4. Indexed triangles<br />
5. Floats vs shorts (turns out shorts are good to feed into openGL)</p>
<p>And I was hoping Riq or some other Cocos2D guru here can see if there's anything that could improve rendering performance of Sprites or AtlasSprites or Particles Systems using some of these techniques.</p>
<p>:)
</p></description>
		</item>

	</channel>
</rss>

