Quickly speed up Silverlight 3 graphics with the GPU enhancements
My last two posts have me drawing over 2,000 graphics objects onto the Virtual Earth Silverlight control. (Each pushpin represents an airport)

One side effect of managing all these objects on screen was high CPU usage:

So this application is pushing my Quad Core machine pretty hard. ( On my dual core laptop, the utilization is about 85% )
Therefore a really easy way to fix this is to use the GPU enhancements in Silverlight 3. By explicitally letting my powerful Garphics card take care of this painting, I can significantly reduce my load.
First I add this property to my Silverlight control:
EnableGPUAcceleration=”true”
For example:
<body>
<form id="form1" runat="server" style="height:100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div style="height:100%;">
<asp:Silverlight ID="Silverlight1" EnableGPUAcceleration="true" EnableFrameRateCounter="true" runat="server"
Source="~/ClientBin/FlightTracks.xap"
MinimumVersion="3.0.40307.0"
Width="100%" Height="100%" /></div>
</form>
</body>
Then simply add a new BitMApCache object to each Image:
Image image = new Image(); image.CacheMode = new BitmapCache(); image.Source = bmp;
That results in the following low CPU utilization:

July 13, 2009 at 10:11 pm
That’s quite a major improvement. I didn’t realise that silverlight used software decoding by default during rendering.
Is there any circumstance where you would not want to set EnableGPUAcceleration?
August 28, 2009 at 11:41 am
Turning on this feature will start using system resources whether or not it is needed, which is probably why it is off by default.
So for a simple custom button implemented in Silverlight, you should keep it turned off.
In my example I actually experimented by applying the BitmapCache object to different levels to determine optimum performance.