Freigeben über


Layered windows...SW is sometimes faster than HW

Previously, I had posted that Avalon’s layered windows on XP will be rendered via the software pipeline. One can create a layered window by setting Window.AllowsTransparency="true". I’ve seen a few forum posts about performance issues, and the key takeaway point is that your mileage will vary depending on your video card.

In order to render layered windows via our hardware pipeline, we need to circumvent the fact that DX Present cannot handle a window with transparency. Instead of using DX present, we render via DX, grab the surface (via GetDC) and present with GDI. GDI is not hardware accelerated on the Vista WDDM video driver model. The above results in a chain of bitblits from video memory to system memory to video memory which creates a performance hit on many video cards. However, with a unified memory model (eg. Intel Lakeport 945g), the rendering of layered windows is faster in hardware than in software, as the bitblit goes from system memory to system memory.

To substantiate the performance hit that could arise from the aforementioned bitblit chain with a few numbers, I did a bit of testing on a card without a unified memory model (nvidia geforce 6800, WDDM video driver). My setup is a recent Vista build, Aero Glass theme, 2.5GHz P4, 1.5 GB RAM, single-monitor, single-video card.

Animating the translation
Scenario: Translating a single 50x50 rectangle around a 300x300 semi-transparent window
Observed: Framerate with hardware acceleration was at ~50 frames/sec. With software, ~ 60frames/sec.

Resizing, forcing an entire redraw
Scenario: With the mouse, resizing an empty 300x300 semi-transparent window with no window style to 300x600
Observed: Framerate was ~8 frames/sec when hardware accelerated. With software, ~60 frames/sec.

Frames with sufficiently complex rendering, particularly 3D, can pass the inflection point and will see a boon to having hardware accelerated layered windows. For layered windows with simple 2D content, our hardware codepath has typically a worse framerate than the software rendering codepath on the video cards without a unified memory model. The enabling of layered windows came late in the game for v1, and we’re looking at developing a more refined codepath for rendering layered windows in vNext, stay tuned.

Key takeaway: a semi-transparent window is a particularly complex feature for WPF's rendering system. Figure out early what type of hardware that you expect your app to run on, the performance that is acceptable for your users, and whether you want to use Window transparency.

Comments

  • Anonymous
    October 26, 2006
    You've been kicked (a good thing) - Trackback from DotNetKicks.com

  • Anonymous
    October 27, 2006
    What did we learn from Windows Vista? MJF sits down with Jim Allchin to find out and we get a very open,

  • Anonymous
    December 08, 2006
    A feature that the WPF team added late to WPF was the ability to allow transparent windows ( property

  • Anonymous
    October 04, 2007
    Hi Seema, Thanks for such an informative post. Out of curiosity, is your post still relevant wrt to how WPF renders layered windows? If so, this validates a suspicion of mine that most of the performance problems I am having in my app is due to the fact its window is layered.

  • Anonymous
    October 10, 2007
    Below is a list of the performance improvements that you can expect to see in WPF in .Net 3.5 and .Net

  • Anonymous
    November 26, 2007
    Below is a list of the performance improvements that you can expect to see in WPF in .Net 3.5 and .Net

  • Anonymous
    October 04, 2008
    WinFX/Avalon and transparent windows

  • Anonymous
    June 06, 2009
    Recently I’ve been getting several questions on hardware acceleration. Some people are running performance