<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<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>Wed, 08 Sep 2010 12:49:38 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</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>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>&#60;p&#62;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).&#60;/p&#62;
&#60;p&#62;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)&#60;/p&#62;
&#60;p&#62;Hope that all makes sense, I will post back here again when I have a full report.
&#60;/p&#62;</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>&#60;p&#62;They mentioned that at the iPhone tech talks, I meant to try it out, but forgot :)&#60;/p&#62;
&#60;p&#62;Any results yet? I'm curious to see how much of an impact this has.
&#60;/p&#62;</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>&#60;p&#62;I got an answer about the padding from none other than Jeff LaMarche (&#60;a href=&#34;http://iphonedevelopment.blogspot.com/&#34; rel=&#34;nofollow&#34;&#62;http://iphonedevelopment.blogspot.com/&#60;/a&#62;)&#60;/p&#62;
&#60;p&#62;Basically I just do this to take care of the struct with 3 shorts in it (6bytes=24bits) to make it (8bytes = 32bits):&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;typedef struct _ccVertex3S
{
    GLshort x;
    GLshort y;
    GLshort z;
    GLshort padding;
} ccVertex3S;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;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.
&#60;/p&#62;</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>&#60;p&#62;Re: the short vs. float thing I found this post on stackoverflow as well:&#60;br /&#62;
&#60;a href=&#34;http://stackoverflow.com/questions/1287811/what-does-the-tiler-utilization-statistic-mean-in-the-iphone-opengl-es-instrument&#34; rel=&#34;nofollow&#34;&#62;http://stackoverflow.com/questions/1287811/what-does-the-tiler-utilization-statistic-mean-in-the-iphone-opengl-es-instrument&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;He claims to get 30% increase in performance by making the change.&#60;/p&#62;
&#60;p&#62;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?&#60;/p&#62;
&#60;p&#62;In preparation for testing all this, I made some new struct types:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;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;&#60;/code&#62;&#60;/pre&#62;</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>&#60;p&#62;Great, thanks Riq. Will do.
&#60;/p&#62;</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>&#60;blockquote&#62;&#60;p&#62;
1. Batch Geometry&#60;br /&#62;
2. Texture Atlases&#60;br /&#62;
3. Interleaved Arrays&#60;br /&#62;
4. Indexed triangles&#60;br /&#62;
5. Floats vs shorts (turns out shorts are good to feed into openGL)
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;cocos2d uses:&#60;br /&#62;
 1,2,3,4 but not 5.&#60;/p&#62;
&#60;p&#62;But if you want to make some performance tests with 5, please, post your results here.
&#60;/p&#62;</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>&#60;p&#62;hmm. ok. +1 bump for Riq being back :)
&#60;/p&#62;</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>&#60;p&#62;Bad time to bump since Riq is away! It looks like good advice on optimizing though.
&#60;/p&#62;</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>&#60;p&#62;+1 week. Maybe no one saw this thread. Bump.
&#60;/p&#62;</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>&#60;p&#62;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) &#60;a href=&#34;http://gamemakers.ngmoco.com/post/111712416/stanford-university-and-apple-were-kind-enough-to&#34; rel=&#34;nofollow&#34;&#62;http://gamemakers.ngmoco.com/post/111712416/stanford-university-and-apple-were-kind-enough-to&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;His example is a particle system that he optimizes by doing the following:&#60;br /&#62;
1. Batch Geometry&#60;br /&#62;
2. Texture Atlases&#60;br /&#62;
3. Interleaved Arrays&#60;br /&#62;
4. Indexed triangles&#60;br /&#62;
5. Floats vs shorts (turns out shorts are good to feed into openGL)&#60;/p&#62;
&#60;p&#62;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.&#60;/p&#62;
&#60;p&#62;:)
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
