<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx</link><description>This article is prerecorded. Shawn is away (getting married later today). Replies to comments will be delayed. Plagiarizing my MIX talk , I thought it would be useful to summarize the performance implications of choosing between the different shader permutations</description><dc:language>en</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10010368</link><pubDate>Mon, 10 May 2010 17:13:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10010368</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;&amp;gt; Exactly, about 60 instances per draw call. And I want 10000+ :)&lt;/p&gt;
&lt;p&gt;So, on platforms that support it, use true hardware instancing. On platforms that do not support hardware instancing, shader instancing is a great alternative.&lt;/p&gt;
&lt;p&gt;Obviously if you want to draw more instances than fit into shader registers, you must split into multiple batches. That's still much faster than doing no instancing at all. Check out eg. our instancing sample, and you will see that shader instancing and hardware instancing are usually about the same speed in practice.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10010368" width="1" height="1"&gt;</description></item><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10010151</link><pubDate>Mon, 10 May 2010 11:47:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10010151</guid><dc:creator>Maurice Sibrandi</dc:creator><description>&lt;p&gt;Exactly, about 60 instances per draw call. And I want 10000+ :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10010151" width="1" height="1"&gt;</description></item><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10009254</link><pubDate>Fri, 07 May 2010 17:35:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10009254</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;&amp;gt; Aren't you very limited in how many instances you can render here?&lt;/p&gt;
&lt;p&gt;Yes, exactly the same as with any implementation of the shader instancing algorithm. From the doc that comes with our Instanced Model sample:&lt;/p&gt;
&lt;p&gt;There is a limit on how many shader instances can be drawn in a single batch. This comes partly from the limited number of shader constant registers available to hold the instance transform matrices (see the comment and MAX_SHADER_MATRICES constant at the top of InstanceModel.fx) and partly from the limited range of 16-bit index values. If we repeated the model data too many times, our 16-bit indices would overflow. We do not want to use 32-bit indices because they are not universally supported on all graphics cards. The InstancedModelPart class stores the result of combining these two batch size limits in the maxInstances field. If asked to draw more copies than this limit, the DrawShaderInstancing method splits up the request, drawing as many instances as possible in each call to DrawIndexPrimitives.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10009254" width="1" height="1"&gt;</description></item><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10009146</link><pubDate>Fri, 07 May 2010 14:40:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10009146</guid><dc:creator>Maurice Sibrandi</dc:creator><description>&lt;p&gt;&amp;gt; Exactly. Skinned character rendering and vertex shader instancing are exactly the same thing, just used to achieve a different goal, so the same shader can be used for both.&lt;/p&gt;
&lt;p&gt;Aren't you very limited in how many instances you can render here? First of all the vertexbuffer needs all the vertexdata for all the instances, but most importantly the instance data has to be set using shaders constants which are limited in size (256?)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10009146" width="1" height="1"&gt;</description></item><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10008783</link><pubDate>Thu, 06 May 2010 21:21:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10008783</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;&amp;gt; Just from thinking about it (not from any kind of documentation), I believe this would be the vertex shader instancing implementation.&lt;/p&gt;
&lt;p&gt;Exactly. Skinned character rendering and vertex shader instancing are exactly the same thing, just used to achieve a different goal, so the same shader can be used for both.&lt;/p&gt;
&lt;p&gt;It is quite trivial to change the shader instancing technique (from the instancing sample on creators.xna.com) to use SkinnedEffect as opposed to the custom shader it uses today.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10008783" width="1" height="1"&gt;</description></item><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10008780</link><pubDate>Thu, 06 May 2010 21:19:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10008780</guid><dc:creator>Justin Olbrantz (Quantam)</dc:creator><description>&lt;p&gt;Re: &amp;quot;I need XNA 4.0. Fix the installer so it will install on Server 2008 (says it only supports Vista and Windows 7&amp;quot;&lt;/p&gt;
&lt;p&gt;Never mind, I just realized the 4.0 CTP only includes phone. Hurry up and get the rest of it done, and make sure that installer works on Server 2008 :P&lt;/p&gt;
&lt;p&gt;Though I do have the exact question Daniel asked: wouldn't the lack of lighting for DualTextureEffect and AlphaTestEffect be a significant disadvantage for some common use scenarios?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10008780" width="1" height="1"&gt;</description></item><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10008779</link><pubDate>Thu, 06 May 2010 21:19:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10008779</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;&amp;gt; I was wondering why the dual texture effect doesnt support any lighting?&lt;/p&gt;
&lt;p&gt;To support every possible permutation of N different shading options is an exponential permutation problem, requiring 2^N different shaders.&lt;/p&gt;
&lt;p&gt;We had the resources to create around 50 different shaders, which would have given us room to support just log2(50) options, which is nowhere near enough to support a range of interesting rendering features.&lt;/p&gt;
&lt;p&gt;Instead, we chose to pick and choose only the more useful combinations of features, so we could support a larger total set of features without having to create an exponential number of different shaders.&lt;/p&gt;
&lt;p&gt;More info in this article: &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/shawnhar/archive/2010/04/28/new-built-in-effects-in-xna-game-studio-4-0.aspx?CommentPosted=true#commentmessage"&gt;http://blogs.msdn.com/shawnhar/archive/2010/04/28/new-built-in-effects-in-xna-game-studio-4-0.aspx?CommentPosted=true#commentmessage&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10008779" width="1" height="1"&gt;</description></item><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10006562</link><pubDate>Mon, 03 May 2010 19:31:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10006562</guid><dc:creator>Justin Olbrantz (Quantam)</dc:creator><description>&lt;p&gt;&amp;quot;I would love to see that trick :)&amp;quot;&lt;/p&gt;
&lt;p&gt;Just from thinking about it (not from any kind of documentation), I believe this would be the vertex shader instancing implementation. That is, each vertex has an associated instance index, and the vertex data is duplicated for each instance (see the instancing sample for more information). In this case, that instance index == the bone index.&lt;/p&gt;
&lt;p&gt;However, this is relatively inefficient, as it requires the vertex list to contain duplicate vertices for ALL instances. The better method is to use hardware instancing where there's only one set of vertex data plus a separate set of instance indices. But I'm guessing SkinnedEffect doesn't support that, as it's a fundamentally different operation than skinning.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10006562" width="1" height="1"&gt;</description></item><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10006213</link><pubDate>Mon, 03 May 2010 09:40:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10006213</guid><dc:creator>Maurice Sibrandi</dc:creator><description>&lt;p&gt;&amp;gt; Neat trick: you can use SkinnedEffect with WeightsPerVertex = 1 to implement shader based instancing.&lt;/p&gt;
&lt;p&gt;I would love to see that trick :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10006213" width="1" height="1"&gt;</description></item><item><title>re: Built-in effects, permutations, and performance</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/30/built-in-effects-permutations-and-performance.aspx#10006210</link><pubDate>Mon, 03 May 2010 09:27:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10006210</guid><dc:creator>DrXner</dc:creator><description>&lt;p&gt;Congratulations on the wedding!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10006210" width="1" height="1"&gt;</description></item></channel></rss>