Skip to main content
Home Forums General Silverlight New Features in Silverlight 3 GPUAcceleration colors
4 replies. Latest Post by Daze55 on July 10, 2009.
(0)
Daze55
Member
227 points
111 Posts
07-10-2009 6:00 AM |
I tried to enable the GPU acceleration on my Silverlight app (because it is completely killing my CPU: average of 50% with peaks to 80% !).When I enable EnableCacheVisualization I can see red colored zones (where hardware acceleration is not applied) and not colored zones (where hardware acceleration is applied).My question is: what do the green colored and blue colored zones mean ?Another question: on which elements acceleration is most effective ?Thank you.
Krasshirsch
Participant
1042 points
300 Posts
07-10-2009 6:14 AM |
I'm not sure about the colors, but to answer your second question.
You should only apply the BitmapCache to objects that not get altered and exist in their current state for a "relative" long time on stage.If an objects only stays on stage for a couple of seconds, thats long enough.
If an objects needs to be redrawn (removed and added to scene) a lot, like once per frame, you should refrain from applying the BitmapCache, since it won't be used and only adds additional overhead which will infact lead to a drop in performance.
The BitmapCache applies to all children, so adding and removing a child within the visual tree will invalidate the cache.So ONLY apply to leafs, not to nodes.
07-10-2009 8:23 AM |
Thank you Krasshirsch for your explanations. An object that is moved (X and Y coordinates changed) can be considered as an altered object ?Here are two screenshot of my app:In this case I set the cacheMode on the whole listBox control (top of the screen):
In this case however I set the cacheMode only on the DataTemplate of the ListBox, so it should only apply on images in it:
You can see the whole colors of the app are changing so what does this exactly means ? Is there an offical documentation available somewhere?Anyway (I will certainly create a new post for that), when you move the scrollbar of the ListBox the CPU reaches and remains used at 80% and this, with or without GPU acceleration. The effects are even worst on the middle component (the one with the circle)Evidently I can't release such an application. If it uses 80% of the CPU on a recent dual core you can imagine the effects on an older computer.I don't know what to think, the animation is done with Storyboards, nothing strange. I think the algorithms that generatse the scrollViewer postion in the ListBox and the one which generates the items of the circle (size, position and zindex) in the middle component are mainly responsible for the cpu use as they are solicited too often, I should find a way to introduce a timeout between two calls.
07-10-2009 9:00 AM |
As I have posted so often, handling the GPU Acceleration correctly is a full time job in Silverlight and hopefully will be changed at some point, but for now lets try to make the best out of it.
When you enable the BitmapCache on an object, it's texture will be stored inside the VRAM.If the item is to be redrawn the GPU will already have it's data inside the VRAM so Silverlight has no need to pass the texture again and can skip it altogether.If any pixel is altered, say you changed a color, or applied a non affine transformation, PointAnimation, etc ..., the texture version inside the VRAM will differ from your new altered texture and will need to be replaced, thus invalidating the cache.Scaling, Moving and Rotating is not considered altering the object, since it doesn't touch the pixel values itself, it just alters their output.
P.S. Do NEVER EVER apply the BitmapCache to a List or Panel or something that carries lots of changing children.If you have a mouse over effect applied to your list items you will not only invalidate this childs cache, but the cache for the entire list and all it's children, since the List includes all it's children into it's cache, you change one, you change them all....You need to apply the cache to LEAFS only.you applied the BitmapCache to the whole List and not seperately to it's children.
07-10-2009 9:54 AM |
Ok thank you, you made the process of caching clearer. Last thing is to understand precisely what this colors mean, it seems they represent kind of levels. In the second case for example, the first control in the hierarchy is the scrollbar (green) then come the others control (blue). Those that remain red...? I don't really know.