Silverlight 5 Hosting :: How to Enable GPU Acceleration on PivotViewer

This is going to be a quick post on using the PivotViewer (both the v1 and the SL5 version).  Every once and a while you realize that you do something out of habit and forget to mention it to anyone, and that was the case here.

I was doing some research into another PivotViewer request when I came across some code inside of the SL5 PivotViewer.  I noticed that when you set a new ItemsSource, it does a check to see if GPU acceleration is enabled or not.  The best I can tell is it will continue on if it isn’t, but a warning message is logged internally to the PivotViewer.

PivotViewer is a graphically intense control.  It only makes sense that it would utilize the GPU whenever necessary so why  not let it?  I have been enabling the GPU acceleration on all of my production PivotViewer applications for some time now.  However, until I came across that line of code, it never really occurred to me to share that little piece of information.

You can find specifics about enabling GPU acceleration in the MSDN documentation.  Although, we will take a look at how to do it here.  Enabling GPU acceleration is as simple as adding a <param> tag to your Silverlight <object> tag in your HTML.  The param that you are adding looks like :

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

He is what your Silverlight object should look like now:

<object data="data:application/x-silverlight-2,"
            type="application/x-silverlight-2"
            width="100%" height="100%">
    <param name="source" value="ClientBin/myproj.xap"/>
    <param name="enableGPUAcceleration" value="true" />
    <param name="onError" value="onSilverlightError" />
    <!-- rest of default object -->
</object>

And that’s it. Now that wasn’t too hard, was it? So now we know how to enable GPU acceleration, but is PivotViewer really using it? I wondered that same thing myself. So I decided to test it out to see what was going on. The Silverlight object has another nifty (yep, I said nifty) little
that allows you to see what objects are taking advantage of GPU acceleration within your application. Now this is not something, for reasons that will be obvious shortly, you will want to leave on in a production environment. However, it can be very useful in testing.

The enableCacheVisualization parameter allows you to see what Silverlight controls are taking advantage of the GPU acceleration.  If a control is using it, then the image remains unchanged.  Elements that are not using it are tented red.  As you might guess, it doesn’t take very long to determine which controls are taking advantage of GPU acceleration.  Let’s add the following <param> to our <object> as :

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

Now when you run your PivotViewer application, you should get something that looks like this:

Our new testing <param> shows us that PivotViewer is GPU acceleration for the trading cards.  Again, this makes sense that PivotViewer would take advantage of it, it’s just not something that everyone takes a moment to consider.

So there you have my PivotViewer tip for today.  As our collections continue to get larger and more complicated, this will hopefully come in handy.  If you have not grabbed the Silverlight 5 RTW stop what you are doing (after you finish this post of course) and go grab it on the Silverlight download page.

Comments are closed.

Sponsors

JaringanHosting.com

Cheap Reseller Hosting

Best Blog Hosting Provider

Best European ASP.NET 4.0 Hosting Provider