Enable GPU Acceleration?

Aug 5, 2010 at 6:30 PM
Edited Aug 5, 2010 at 7:45 PM

Do you recommend enabling GPU Acceleration for web applications that include a Balder Game control?

<body>
    <form id="form1" runat="server" style="height:100%">
    <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
         <param name="source" value="ClientBin/xxx.xap"/>
         <param name="onError" value="onSilverlightError" />
         <param name="background" value="white" />
         <param name="minRuntimeVersion" value="4.0.50401.0" />
         <param name="autoUpgrade" value="true" />
        <param name="EnableGPUAcceleration" value="true" />   <= Enable GPU Acceleration ? 
        <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
         </a>
         </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
    </form>
</body>
</html>

If so, do we also need to specify the cache mode as shown below?

DirectionalLight directionalLight = new DirectionalLight() {
    Direction = new Coordinate(0, 0, 10),
    Diffuse = Colors.White,
    SpecularIntensity = 1.5d
};
Heightmap heightMap = new Heightmap() {
    Dimension = new Dimension() {
        Height = 100,
        Width = 100
    },
    LengthSegments = (int)this.SliderGrid.Value,
    HeightSegments = (int)this.SliderGrid.Value,
    Cursor = System.Windows.Input.Cursors.Hand,
    CacheMode = new System.Windows.Media.BitmapCache() { *** Here? ***
        RenderAtScale = 1d
    }
};
heightMap.Prepared += (o, f) => {
    this.UpdateFaces();
};

this._game = new Game() {
    Height = this.GridMap.ActualHeight,
    Width = this.GridMap.ActualWidth,
    Camera = new Camera() {
        Position = new Coordinate(0, 0, 0),
        Target = new Coordinate(0, 0, 0)
    },
    Opacity = 0d,
    CacheMode = new System.Windows.Media.BitmapCache() { *** Here? ***
        RenderAtScale = 1d
    }
};
this._game.Children.Add(directionalLight);
this._game.Children.Add(heightMap);
this.GridMap.Children.Insert(0, this._game);

 

Thanks,
Richie

 

 

Coordinator
Aug 5, 2010 at 9:52 PM

Hi,

excellent question, something I really haven't thought about. 

I must admit that I'm not sure wether or not this would have any benefits. For the BitmapCache, enabling that shouldn't have any effect as the image changed 60 times a second and really nothing to cache. If it would have any effect, it would only have effect enabling it on Game.

I will run some tests for this, interesting to know and be able to give a clear answer. 

 

 

Coordinator
Aug 12, 2010 at 7:26 AM

DId some testing, can't say that it has any effect.

If you're using the Skybox feature though, with the latest source code you should see some different as its using the Perspective Transform in Silverlight to actually draw them.