Question

I'm optimizing a silverlight application which uses a lot of images (GIS style, display tiled images, zoom/pan/etc.), and I was thinking of using the bitmapcaching functionality which should offload a bunch of things to the GPU.

However, I can't seem to get it to work. My host page contains the correct params (I think?):

    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
        <param name="EnableCacheVisualization" value="true" />
        <param name="EnableGPUAcceleration" value="true" />
        <param name="EnableFramerateCounter" value="true" />
      <param name="source" value="ClientBin/BitmapCaching.xap"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="5.0.61118.0" />
      <param name="autoUpgrade" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration:none">
          <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
      </a>
    </object>

And my xaml should enable caching as well:

<UserControl x:Class="BitmapCaching.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White" CacheMode="BitmapCache">
        <Rectangle x:Name="img" Width="200" Height="200" Stroke="Black">
            <Rectangle.Fill>
                <ImageBrush ImageSource="/BitmapCaching;component/download.jpg" />
            </Rectangle.Fill>
            <Rectangle.RenderTransform>
                <RotateTransform />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Button Content="Scale" Height="40" Width="100" Click="Button_Click" />
    </Grid>
</UserControl>

(yes, I know it's not smart to put the cachemode on the root element)

However, when I launch the application, The complete application shows up with a red tinted overlay. This should indicate that there's nothing being cached.

I've read that you need a recent driver for your GFX card, but that should be fine. This machine has an ATI Radeon HD5450 videocard with recent drivers. I can't imagine that's not enough?

I'm stumped. If anyone knows how to solve this, please, save me from going insane!

Was it helpful?

Solution

I believe MS screwed up the documentation on this property.

The docs states that a tint will show up if it is NOT accelerated, and untinted if it IS accelerated. This is true, but for a different property: enableRedrawRegions!

This property is similiar to EnableCacheVisualization, but it changes the color for every redraw. So if you turn on enableRedrawRegions, you will see the redraws as they occur. I find this much easier to visualize the redrawing which is occuring.

By turning on/off GPU Accleration, you will see that with GPU on, there are no redraws of animated by the cpu (it being done by the gpu instead)objects. With it off, you will see many redraws.

Then turn off enableRedrawRegions and turn EnableCacheVisualization on. You will see that with GPU acceleration off, everything looks normal. Turn it on, and everything looks colored. Meaning that colored DOES mean accelerated, the opposite of what the docs state.

A good project to test this on is from this blog: http://andybeaulieu.com/Home/tabid/67/EntryID/193/Default.aspx. It shows a spinning phone which benefits from CPU acceleration and by toggling the properties, you can see what is going on with the GPU.

Greg

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top