Page view counter

Silverlight Tips of the Day - Blog by Mike Snow

Game Programming with Silverlight

Silverlight Tip of the Day #105 – How to Enable GPU Acceleration

With the release of Silverlight 3 Beta 1 GPU (Graphics Processing Unit) acceleration (or hardware acceleration) is now available. The GPU is a processor attached to your graphics card that is generally used for calculating floating point operations. In addition, it contains a number of graphics primitives that when used will save you a lot of CPU time.

By default this option is disabled and to use it you must enable it both on your Silverlight control/plug-in as well as any of the controls you want to leverage it.

To enable it on your Silverlight control open your web page that hosts the Silverlight control.

For HTML modify the Silverlight control to include the following param:

<param name="EnableGPUAcceleration" value="true" />

For ASPX add the following attribute:

<asp:Silverlight ID="Silverlight1" EnableGPUAcceleration="true" runat="server" Source="~/ClientBin/MyApp.xap" MinimumVersion="3.0.40307.0" Width="100%" Height="100%" />

Now, to apply it to a control you will need to add CacheMode="BitmapCache” to the control. The following example shows you how to add it to an Image control:

<Image CacheMode="BitmapCache" Source="MyImage.png"></Image>

Currently BitmapCache is the only option. What this does is it causes visual elements (and all their children) to be cached as bitmaps after they have already been rendered. Once cached, your application can bypass the expensive rendering phase for the cached elements and just display them.

If you want to test out what is being cached in your application add the following attribute to your Silverlight control:

<asp:Silverlight EnableCacheVisualization="true" ID="Silverlight1" EnableGPUAcceleration="true" runat="server" Source="~/ClientBin/MyAPp.xap" MinimumVersion="3.0.40307.0" Width="100%" Height="100%" />

Uncached objects will appear tinted where as cached objects will not be tinted.

This feature is supported on:

  1. Windows: Both full screen and non-full screen
  2. Mac: Full screen only.

This feature should be used when the following are occurring to your control:

  1. Transformations (translating, rotating, stretching, etc.).
  2. Clipping.
  3. Blending.

 

Thank you,
--Mike Snow

 Subscribe in a reader 

Comments

Microsoft Weblogs said:

With the release of Silverlight 3 Beta 1 GPU (Graphics Processing Unit) acceleration (or hardware acceleration

# April 1, 2009 5:41 PM

DotNetShoutout said:

Thank you for submitting this cool story - Trackback from DotNetShoutout

# April 3, 2009 2:56 AM

Visual Web Developer Team Blog said:

Most Recent Posts: Silverlight Tip of the Day #106 - Setting Default Browser from within VS Silverlight

# April 6, 2009 6:13 PM

Silverlight Tips of the Day - Blog by Mike Snow said:

The purpose of this post is to create an outline summary all the blogs from my Silverlight Tips of the

# April 6, 2009 6:20 PM

Canine tooth » Blog Archive » AccelerEyes said:

Pingback from  Canine tooth  &raquo; Blog Archive   &raquo; AccelerEyes

# May 7, 2009 4:10 AM

Bezhta language | Radeon R600 said:

Pingback from  Bezhta language | Radeon R600

# May 11, 2009 3:39 PM

Censorship in the Republic of Ireland » Shader said:

Pingback from  Censorship in the Republic of Ireland &raquo; Shader

# July 6, 2009 7:41 PM

NewsPeeps said:

Thank you for submitting this cool story - Trackback from NewsPeeps

# August 8, 2009 6:36 PM

Twitter Trackbacks for Object moved [silverlight.net] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 Object moved         [silverlight.net]        on Topsy.com

# August 30, 2009 1:54 PM

bartczernicki said:

This tip is slightly out of date.  The ASP.NET Silverlight control in Silverlight 3 is deprecated and doesn't include the EnableGPUAcceleration...you need to use the JavaScript object.

Note: this is if you don't use the open source .NET wrapper, which I would not.

# January 10, 2010 8:34 PM

Frank La Vigne said:

# January 25, 2010 5:15 PM

AVforum.no - N?tt for ekspertene : Problemer med Acer Revo r3610 said:

Pingback from  AVforum.no  - N?tt for ekspertene : Problemer med Acer Revo r3610

# August 20, 2010 4:54 AM

AVforum.no - N?tt for ekspertene : Problemer med Acer Revo r3610 said:

Pingback from  AVforum.no  - N?tt for ekspertene : Problemer med Acer Revo r3610

# August 20, 2010 6:44 PM

webtasarim said:

The effects of positive direction on Silverlight gpu..

# July 2, 2011 9:35 AM