<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Greg Schechter's Blog : DWM</title><link>http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx</link><description>Tags: DWM</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>The word is - "Java on Vista: Yes, it Works"</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/10/09/The-word-is-_2D00_-_2200_Java-on-Vista_3A00_-Yes_2C00_-it-Works_2200_.aspx</link><pubDate>Mon, 09 Oct 2006 23:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:810045</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/810045.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=810045</wfw:commentRss><description>&lt;P&gt;Some folks have noticed that when they run Java applets in the browser, that Aero and desktop composition would get disabled.&amp;nbsp; This was due to Java locking the primary buffer, and when that happens, the DWM no longer has access to the resources needed to draw the desktop, therefore we disable desktop composition.&amp;nbsp; Sun has since addressed this issue, as you can see in &lt;A class="" href="http://weblogs.java.net/blog/chet/archive/2006/10/java_on_vista_y.html" mce_href="http://weblogs.java.net/blog/chet/archive/2006/10/java_on_vista_y.html"&gt;this post&lt;/A&gt; in &lt;A class="" href="http://weblogs.java.net/blog/chet/" mce_href="http://weblogs.java.net/blog/chet/"&gt;Chet Haase's&lt;/A&gt; blog.&amp;nbsp; Chet also provides lots more detail about what was up, what version it's fixed in, and when it will be available - or, as &lt;A class="" href="http://bubbleman.com/" mce_href="http://bubbleman.com/"&gt;BubbleMan&lt;/A&gt; insists on saying, availabubble.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;And while we're on the topic, earlier versions of Apple's QuickTime/iTunes also exhibited this primary-locking behavior.&amp;nbsp; The lastest updates to QuickTime/iTunes no longer does this.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=810045" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>A Couple of Cool Uses of the DWM Thumbnail APIs</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/09/27/775027.aspx</link><pubDate>Thu, 28 Sep 2006 09:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:775027</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/775027.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=775027</wfw:commentRss><description>&lt;P&gt;I've seen a couple of cool uses in the past week of the DWM Thumbnail API (described in my &lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/09/14/753605.aspx"&gt;previous post&lt;/A&gt;) and wanted to share them here.&lt;/P&gt;
&lt;P&gt;"&lt;A href="http://blogs.labo-dotnet.com/simon/"&gt;Simon on the .NET&lt;/A&gt;" wrote a great-looking&amp;nbsp;&lt;A href="http://blogs.labo-dotnet.com/simon/archive/2006/09/12/11116.aspx"&gt;Exposé-like mini-app &lt;/A&gt;that, when you press F12, shows a representation of all the desktop windows in a grid.&amp;nbsp; The original desktop is shown behind the grid.&amp;nbsp; The thumbnails are, as expected, live and updating (though they don't&amp;nbsp;accept input, as is true with DWM thumbnails in general).&lt;/P&gt;
&lt;P&gt;&lt;A href="http://11011.net"&gt;Douglas Stockwell&lt;/A&gt; wrote a &lt;A href="http://11011.net/archives/000651.html"&gt;cool WPF application &lt;/A&gt;that PInvoke's to the thumbnail APIs and populates a WPF ItemsControl with thumbnails of windows as you click on them.&amp;nbsp; As it stands, it has no particular purpose, but it shows some interesting integration between WPF and DWM thumbnails.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=775027" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/WPF/default.aspx">WPF</category></item><item><title>APIs in the Desktop Window Manager</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/09/14/753605.aspx</link><pubDate>Thu, 14 Sep 2006 11:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:753605</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/753605.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=753605</wfw:commentRss><description>&lt;P&gt;For the most part, the Vista Desktop Window Manager is an end-user feature.&amp;nbsp; However, because it so fundamentally changes the game of how the desktop gets composed, there was both the opportunity and the requirement to introduce a relatively small number of APIs that impact how the DWM operates, and allows the programmer to take advantage of DWM features.&amp;nbsp; This post will discuss the functionality and APIs that we expose at a fairly high level, and reference MSDN documentation for drilling further in.&lt;/P&gt;
&lt;P&gt;The DWM APIs are housed in dwmapi.dll, with declarations in dwmapi.h.&amp;nbsp; dwmapi.dll is a very thin DLL that in almost all instances, simply LPC's over to the dwm.exe process in order to fulfill the API request.&amp;nbsp; The DWM-related APIs fall into a number of categories:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Information querying and setting functionality&lt;/LI&gt;
&lt;LI&gt;Scheduling and media presentation&lt;/LI&gt;
&lt;LI&gt;Thumbnail registration manipulation&lt;/LI&gt;
&lt;LI&gt;Client-area blur/glass manipulation&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;You can get more information about each of these in MSDN by searching at &lt;A href="http://windowssdk.msdn.microsoft.com/"&gt;http://windowssdk.msdn.microsoft.com&lt;/A&gt;.&amp;nbsp; The point of this post is to try to tell a coherent story about the set of them, that hopefully contains some of the motivation.&lt;/P&gt;
&lt;H3&gt;Information Querying and Setting&lt;/H3&gt;
&lt;P&gt;There are a number of functions that provide basic information for querying and setting certain window and system attributes:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;DwmEnableComposition - enables and disables composition.&lt;/LI&gt;
&lt;LI&gt;DwmIsCompositionEnabled - returns whether or not composition is occurring.&lt;/LI&gt;
&lt;LI&gt;DwmGetColorizationColor - returns the current window colorization information.&lt;/LI&gt;
&lt;LI&gt;Dwm{Set,Get}WindowAttribute - controls various attributes on windows, including the policy for rendering the non-client area; policies on the "thumbnail representation" for a window -- whether it should truly be a thumbnail, or be an iconic representation;&amp;nbsp; how Flip3D treats a window; enable/disable DWM transitions for a window; policy controlling client's NC area painting; access to caption button bounds; etc.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Also, there are a number of Windows messages sent under different circumstances:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;WM_DWMCOLORIZATIONCOLORCHANGED -- when the colorization color changes, apps can react to it as they see fit (for instance, if they have elements of their client area colored based on the colorization color.&lt;/LI&gt;
&lt;LI&gt;WM_DWMCOMPOSITIONCHANGED -- when composition is turned on or off, this message is broadcast&lt;/LI&gt;
&lt;LI&gt;WM_DWMNCRENDERINGCHANGED -- when the non-client area rendering status of a window has changed&lt;/LI&gt;
&lt;LI&gt;WM_DWMWINDOWMAXIMIZEDCHANGE - windows can register to hear about when other windows have been maximized.&amp;nbsp; This is useful for, for instance, the TaskBar or the SideBar which go opaque when other windows get maximized.&lt;/LI&gt;&lt;/UL&gt;
&lt;H3&gt;Scheduling and Media Presentation&lt;/H3&gt;
&lt;P&gt;These functions allow for finer grained control of exactly when the desktop is composited and presented.&amp;nbsp; This is typically needed by media and video-playback applications for whom the DWM is running asynchronously from their own presentation schedule, which can lead to sampling artifacts if not tightly controlled.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;DwmEnableMMCSS -- allows the DWM to participate in the Multimedia Class Schedule Service to have stronger control over the use of CPU resources in conjunction with another app using MMCSS (typically for video playback)&lt;/LI&gt;
&lt;LI&gt;DwmGetCompositionTimingInfo -- provides information about the rate at which the DWM is composing, how many frames are completed, how many are pending, dropped frames, etc.&lt;/LI&gt;
&lt;LI&gt;DwmModifyPreviousDxFrameDuration, DwmSetDxFrameDuration, DwmSetPresentParameters -- these allow applications to queue up multiple DirectX surfaces for presentation and precisely control when they're to be presented.&amp;nbsp; They're typically used by video presentation applications to counteract the latency that's inherent in a compositing system.&lt;/LI&gt;&lt;/UL&gt;
&lt;H3&gt;Thumbnail Registration and Manipulation&lt;/H3&gt;
&lt;P&gt;Thumbnails in the DWM are not static snapshots of a window.&amp;nbsp; They're dynamic, constant connections between a thumbnail source window, and a place on a target window that that source window will get a "thumbnail rendering".&amp;nbsp; Thus, a thumbnail is really a registration between a source HWND and a destination HWND.&amp;nbsp; Once a thumbnail is registered, one can update it's properties like the source and destination rectangles, opacity, visibility, and whether the source's NC area should be part of the thumbnail.&lt;/P&gt;
&lt;P&gt;The functions available for thumbnail manipulation are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;DwmRegisterThumbnail -- establish a relationship between a source HWND and a destination HWND, and return a new thumbnail ID.&lt;/LI&gt;
&lt;LI&gt;DwmUnregisterThumbnail -- end the relationship represented by the thumbnail ID.&lt;/LI&gt;
&lt;LI&gt;DwmUpdateThumbnailProperties -- update source/destination rectangles, opacity, visibility, etc.&lt;/LI&gt;
&lt;LI&gt;DwmQueryThumbnailSourceSize -- helper function ot figure out the source window size from a thumbnail, which is otherwise painful to figure out on your own.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The way thumbnails are implemented is effectively via the same VisualBrush mechanism that we have in WPF.&amp;nbsp; The DwmRegisterThumbnail API effectively creates a link into a node representing a window in the visual tree that makes up the desktop (discussed in &lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/06/09/623566.aspx"&gt;this post&lt;/A&gt;), and references that node from the thumbnail target HWND.&amp;nbsp; Thus when the thumbnail source is a live video, the target HWND is rendered by rendering that live video there as well.&amp;nbsp; So these thumbnails are very much "live".&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I should also point out here that things like Flip3D &lt;U&gt;cannot&lt;/U&gt; be built using the thumbnail API.&amp;nbsp; That's because thumbnails are always rendered head on in their target window in 2D.&lt;/P&gt;
&lt;P&gt;Because of how thumbnails work as described here, it's possible to make interesting topologies of thumbnails -- for instance, having a thumbnail of another thumbnail, and nested further than that, is perfectly viable (though cycles are prohibited and checked for).&amp;nbsp; Having an application show many thumbnails in a window is just fine and in fact is exactly what Alt-Tab does in Vista Aero.&amp;nbsp; Thumbnails can also be any size -- in fact, they can even be larger than their original source.&lt;/P&gt;
&lt;P&gt;Even though the Client-Area Blur/Glass APIs described below have gotten more initial attention in the community, I'm hopeful that the thumbnail APIs will be put to really interesting uses.&amp;nbsp; They really hold the promise of some very, very interesting uses.&amp;nbsp; So if you're out there reading this -- get inspired and do something cool with these and let me know... I'd love to post about it.&lt;/P&gt;
&lt;H3&gt;Client-Area Blurred Glass Manipulation&lt;/H3&gt;
&lt;P&gt;Lastly, there's the set of APIs for adding the blurred glass affect to the client area of your windows.&amp;nbsp; Many windows in Vista use this -- the Explorer and IE for their bread-crumb bar.&amp;nbsp; Windows Media Player for its transport controls.&amp;nbsp; Photo Gallery for its manipulation controls.&amp;nbsp; The Sidebar Gadget Picker puts its Gadgets on a big pane of glass.&amp;nbsp; The Alt-Tab UI is on a big pane of glass.&amp;nbsp; There are two primary means of getting blurred glass in your client area.&amp;nbsp; I'll explain with the first two function definitions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;DwmExtendFrameIntoClientArea - this insets from the margins and makes a border inset within the client area merge seamlessly with the blurred glass of the window frame. &lt;/LI&gt;
&lt;LI&gt;DwmEnableBlurBehindWindow - this allows a GDI HRGN to be specified on a window, and the DWM will blur what's behind that region.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;In both of these cases, it's the complete responsibility of the application to ensure that the areas being presented that will now have blurred glass behind them are rendered with the proper transparency values in the alpha channel.&amp;nbsp; Unfortunately, very few GDI functions respect alpha (really the "alpha blit" function in GDI is the only one that reliably does).&amp;nbsp; Thus you may be forced to render your GDI content offscreen, use memory operations to clean up the alpha channel, and then alpha blit back.&lt;/P&gt;
&lt;P&gt;There's been a fair amount written in the community around how to use Client-Area Blurred Glass in your applications.&amp;nbsp; Here are some choice examples:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Tim Sneath &lt;A href="http://blogs.msdn.com/tims/archive/2006/04/18/578637.aspx"&gt;shows how to do client area glass in a Windows Forms application&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;Adam Nathan &lt;A href="http://blogs.msdn.com/adam_nathan/archive/2006/05/04/589686.aspx"&gt;shows how to do client area glass in a WPF application&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;Martin Grayson &lt;A href="http://blogs.msdn.com/mgrayson/archive/2006/09/07/743976.aspx"&gt;provides a WPF example&lt;/A&gt; as well.&lt;/LI&gt;
&lt;LI&gt;Daniel Moth also &lt;A href="http://www.danielmoth.com/Blog/2006/07/glass-in-c-alternative-approach.html"&gt;provides a few more uses&lt;/A&gt;.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;It's very important though to realize and honor the performance implications of using blurred glass in more parts of your window.&amp;nbsp; Since you can see through, updates in windows behind that otherwise wouldn't have caused repaints now do cause repaints.&amp;nbsp; And the blurring itself is a somewhat expensive operation that happens in the GPU.&amp;nbsp; So blurred glass should really be used sparingly in applications, and to good design purpose.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=753605" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>Responding to Comments on "High DPI Support in Windows Aero Vista"</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/09/14/753467.aspx</link><pubDate>Thu, 14 Sep 2006 10:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:753467</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/753467.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=753467</wfw:commentRss><description>&lt;P&gt;I received a number of great comments and questions on my last post about &lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/08/07/690704.aspx"&gt;High DPI Support in Windows Aero Vista&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Adrian&lt;/B&gt; makes a very solid point about applications that do in fact work correctly at high DPI, and scale appropriately, and in general are very good "DPI citizens", however, they haven't set the manifest for Vista to claim that they're DPI aware (and of course they haven't, since Vista wasn't around when they wrote their apps).&amp;nbsp; These are applications that Vista will think are not DPI-aware, and subject them to bitmap scaling rather than letting them render at the true resolution, resulting in a worse experience.&amp;nbsp; This is an issue that we've struggled with on the team, since we don't want to make the experience worse for apps that have gone to this trouble, yet we do want to provide the benefit for the large number of apps that haven't.&amp;nbsp; Based on these conversations, we've made some changes post-RC1 that we hope will ease this issue substantially.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Chris Nahr&lt;/B&gt; makes a general comment about font scaling, and &lt;B&gt;Joe&lt;/B&gt; asks about ClearType.&amp;nbsp; In both of these cases, rendering windows scaled will result in blurrier, and possibly color fringed text, and without hinting at the larger sizes.&amp;nbsp; But that's all because the application doesn't do the high DPI aware re-rendering themselves.&amp;nbsp; Those apps that do (see above) we certainly want them to continue to do.&amp;nbsp; The High DPI Scaling feature is really targeted at the very large class of applications that don't do this, for which at very large DPI settings, lack of font hinting or potential color fringing is a lesser evil than tiny rendering.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Raiker&lt;/B&gt; mentions scaling on vector interfaces good, scaling on bitmaps bad.&amp;nbsp; We couldn't agree more.&amp;nbsp; However, the reality is that most apps are not built on vector-based systems, and those that are can be DPI-aware and scale in a DPI-aware form providing all the benefits of a vector-based system.&amp;nbsp; This feature is really for the very large class of apps that don't do DPI-aware rendering and are not vector based.&amp;nbsp; If you look at Windows Presentation Foundation applications, for instance, those are all DPI aware apps, and will do the full-on vector-scaling thing without being bitmap-scaled by the High DPI feature.&lt;/P&gt;
&lt;P&gt;Finally, &lt;B&gt;Michael Giagnocavo&lt;/B&gt; talks about Vista Beta 2 DPI scaling being unusable.&amp;nbsp; Many issues have been fixed then and you'll find a much better experience in RTM and in the RC1 that's out now.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=753467" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>High DPI Support in Windows Vista Aero</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/08/07/690704.aspx</link><pubDate>Mon, 07 Aug 2006 10:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:690704</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>21</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/690704.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=690704</wfw:commentRss><description>&lt;p&gt;A good amount of ink has been spilled on this blog talking about all the 
cost, nuance, impact, and techniques we go through to get a composited desktop.&amp;nbsp; 
Less ink is spilled on the benefits of the composited desktop.&amp;nbsp; Those were 
most broadly covered in
&lt;a href="http://blogs.msdn.com/greg_schechter/archive/2006/03/05/544314.aspx"&gt;
this initial post&lt;/a&gt;.&amp;nbsp; I'd like to expand on one such benefit here -- High 
DPI Support (or High Resolution Support).&lt;/p&gt;
&lt;p&gt;Monitor resolutions are going up while prices are going down.&amp;nbsp; In 
general, pixel density is going up as well.&amp;nbsp; Both on laptops that are 
regularly 120 DPI and 144 DPI these days (as opposed to the typical desktop 
experience of 96 DPI), and on desktops that are getting bigger and denser 
monitors.&amp;nbsp; This can make for crisper, less jagged display of content.&amp;nbsp; 
However, in order for this to work, applications typically need to do work to 
deal with different display resolutions.&amp;nbsp; (This is not always true... for 
instance, Windows Presentation Foundation applications are natively 
resolution-aware, and the application developer needn't worry about it.)&amp;nbsp; 
When applications aren't written to adapt to different resolutions, they just 
start to look smaller and smaller on higher and higher resolution monitors.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;The seminal article for how to write your GDI/GDI+ applications to be DPI 
aware was written way back in 2001 by my colleague
&lt;a href="http://blogs.msdn.com/nickkramer/"&gt;Nick Kramer&lt;/a&gt;, and can be found
&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngdi/html/highdpiapp.asp"&gt;
here&lt;/a&gt;.&amp;nbsp; This is ultimately the best approach an application can take.&amp;nbsp; 
However, not all applications do this, and yet users of course use these 
applications while they're running in a higher DPI environment.&amp;nbsp; This is 
where the composited desktop re-enters the picture.&amp;nbsp; As you recall, when 
the DWM is running, applications render to an offscreen bitmap.&amp;nbsp; When the 
DWM recognizes that an app is not DPI aware and just rendering as it always 
does, but that the desktop is set to a non-standard DPI, then the DWM goes ahead 
and renders the window at a larger size.&lt;/p&gt;
&lt;p&gt;This &amp;quot;rendering at a larger size&amp;quot; results in the app being somewhat fuzzier 
and not as crisp as if it were being rendered natively at the correct 
resolution.&amp;nbsp; However, it's the &amp;quot;correct&amp;quot; size for everything else on the 
desktop, and typically represents the much better option between rendering at 
the right size somewhat fuzzily; or crisply but at a size much too small.&lt;/p&gt;
&lt;p&gt;For the purposes of this blog, there are some interesting tidbits about the 
High DPI rendering that are worth discussing:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;As
	&lt;a href="http://blogs.msdn.com/greg_schechter/archive/2006/05/02/588934.aspx"&gt;
	this earlier post&lt;/a&gt; describes, the client area of the window is just a 
	bitmap.&amp;nbsp; Because of the way the DWM works and how it sits atop WPF 
	technology and thus atop DirectX, scaling the client area is really just a 
	matter of modifying a scale transform on the appropriate node of the &amp;quot;visual 
	tree&amp;quot; that describes the desktop.&amp;nbsp; This notion was described
	&lt;a href="http://blogs.msdn.com/greg_schechter/archive/2006/06/09/623566.aspx"&gt;
	here&lt;/a&gt;.&lt;/li&gt;
	&lt;li&gt;When that transform scaling is performed on the visual tree, ultimately 
	in DirectX, this results in performing a texturing operation with the same 
	sized texture but a larger mesh (the target client area), resulting in 
	stretching the client area bitmap.&amp;nbsp; &lt;/li&gt;
	&lt;li&gt;The Non-Client Area (the window frame) is not scaled uniformly with the 
	client area.&amp;nbsp; As in non-DPI scaled situations, it's &amp;quot;painted&amp;quot; 
	separately.&amp;nbsp; It's not simply subjected to bitmap scaling because for 
	the frame, we &lt;i&gt;can&lt;/i&gt; natively scale it, and choose elements appropriate 
	for the target resolution, render caption text appropriate for the target 
	resolution, etc.&lt;/li&gt;
	&lt;li&gt;While one can imagine any scale factor coming about as a function of the 
	target DPI resulting in windows that land off of pixel boundaries and 
	represent fractional pixel contribution.&amp;nbsp; However, we avoid this and 
	clamp our scaling so that we always remain on pixel boundaries and remain as 
	crisp as possible, within the confines of the graphical filtering algorithm 
	in place.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;More details for the app developer:&amp;nbsp; &lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;The preferred mechanism by which an application will be able to declare 
	itself High DPI aware under Windows Vista will be via the manifest.&amp;nbsp; 
	Look for upcoming MSDN documentation discussing how to do this.&amp;nbsp; In the 
	event where a manifest isn't appropriate/available (for instance, when 
	writing a library or framework), the the library should ensure that the &amp;quot;&lt;a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms633543.aspx"&gt;SetProcessDPIAware&lt;/a&gt;&amp;quot; 
	API is called before creating any UI.&lt;/li&gt;
	&lt;li&gt;
	&lt;a href="http://blogs.msdn.com/nickkramer/archive/2006/04/12/574587.aspx"&gt;
	Nick writes a bit more&lt;/a&gt; about High DPI in the context of USER and GDI 
	compatability.&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=690704" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>How underlying WPF concepts and technology are being used in the DWM</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/06/09/623566.aspx</link><pubDate>Fri, 09 Jun 2006 11:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:623566</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/623566.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=623566</wfw:commentRss><description>&lt;P&gt;In the earlier posts I've done on the DWM, there's been a hint of the relationship between it and the &lt;A href="http://msdn.microsoft.com/winfx/technologies/presentation/default.aspx"&gt;Windows Presentation Foundation&lt;/A&gt; (WPF, aka Avalon).&amp;nbsp; This post delves deeper into that relationship.&amp;nbsp; Because of core OS component requirements (the desktop itself of course being a core OS component) regarding the use of managed code, the DWM itself is &lt;U&gt;not&lt;/U&gt; a managed application that directly uses WPF.&amp;nbsp; However, in almost all other ways, the DWM really can and should be thought of as a WPF application.&amp;nbsp; Most importantly, it does use the same native composition and rendering module, milcore.dll, used by WPF itself, and it uses it in ways very similar to how WPF uses it.&lt;/P&gt;
&lt;P&gt;By the way, I recently did &lt;A href="http://channel9.msdn.com/Showpost.aspx?postid=190253"&gt;this Channel9 video&lt;/A&gt; about aspects of what's discussed here.&lt;/P&gt;
&lt;P&gt;Before going further, a quick detour on how WPF applications work.&amp;nbsp; The application author creates, through XAML or code, a tree of elements that becomes the applications "visual tree".&amp;nbsp; This visual tree is communicated to the WPF rendering thread as a data structure, and the rendering thread now is responsible for traversing this visual tree and drawing its pixels.&amp;nbsp; When the application wants to make changes to what is shown, the code they execute results in edits to the visual tree, and the rendering thread re-renders what needs to be re-rendered.&amp;nbsp; This process of walking this tree and issuing rendering calls is known as "composition".&amp;nbsp; In a WPF application, the composition and rendering work are done in the milcore.dll module.&lt;/P&gt;
&lt;P&gt;So, that's a WPF application.&amp;nbsp; What about the desktop itself?&amp;nbsp; The DWM models the desktop as a visual tree where each node in the tree is a window.&amp;nbsp; And each of these "window" nodes consists of nodes below it that represent the non-client area (frame) and the client area of the window.&amp;nbsp; It so happens that the client area of the window happens to be a shared DirectX surface that comes from window redirection as described in &lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/05/02/588934.aspx"&gt;this earlier post&lt;/A&gt;, but from the point of view of the composition engine, the whole desktop is pretty much just another visual tree.&amp;nbsp; (There's no denying, though, that it's not just any old other visual tree... there are certainly some special optimizations we needed to make in order to get the desktop to the level of performance that it needed to be, but we also hope that those optimizations can make their way back for general WPF usage.)&lt;/P&gt;
&lt;P&gt;OK, so now that we've gotten the desktop to look like a visual tree, and even with it being a natural fit, the obvious question comes up: Why?&amp;nbsp; Why bother?&amp;nbsp; What do we gain from this?&amp;nbsp; Why not write the DWM straight to DirectX?&lt;/P&gt;
&lt;P&gt;There are a number of substantial benefits that come from building on a general compositing and rendering system.&amp;nbsp; Here are some of them:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Remoting support - the DWM itself can be remoted, and that uses the underlying WPF remoting support.&lt;/LI&gt;
&lt;LI&gt;Multiple monitor abstraction - the DWM application needn't concern itself with most of the aspects of how to render across multiple monitors or adapters.&lt;/LI&gt;
&lt;LI&gt;Integration of 3D with 2D - the Flip3D feature and the window transitions use 3D integrated into the 2D visual tree.&amp;nbsp; This support is a key WPF differentiator.&lt;/LI&gt;
&lt;LI&gt;2D tesselated anti-aliased primitives - the underlying WPF technology takes care of this.&lt;/LI&gt;
&lt;LI&gt;Update management - as changes are made to the visual tree based on desktop activity by the user, the write invalidations and change propagation occurs in the visual tree.&lt;/LI&gt;
&lt;LI&gt;Dirty region management - code within the composition engine ensures that only the regions of the display that are dirty need to be re-rendered, which is an absolutely vital performance requirement.&lt;/LI&gt;
&lt;LI&gt;Occlusion culling support - similar to dirty region management, occlusion culling support allows the composition engine not to render content that's changing if it's covered by another part of the visual tree that's opaque.&lt;/LI&gt;
&lt;LI&gt;Scheduling - scheduling of frames, maintenance of frame rate, compensation for variability in frame rate is all part of the scheduling subsystem.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;All of these benefits come from the use of WPFs composition system.&lt;/P&gt;
&lt;P&gt;I'm 95% sure the following question will come up, so let's get it out of the way here:&amp;nbsp; &lt;I&gt;Is milcore.dll available for public use?&amp;nbsp; &lt;/I&gt;The answer is that in the Windows Vista timeframe, it is not exposed as a public API.&amp;nbsp; We are certainly looking into what would be involved in exposing it, and clearly understand that there's interest out there for it.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=623566" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/WPF/default.aspx">WPF</category></item><item><title>I'm on TV... and just in time for Mother's Day...</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/05/09/594267.aspx</link><pubDate>Wed, 10 May 2006 09:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:594267</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/594267.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=594267</wfw:commentRss><description>&lt;P&gt;I got to do&amp;nbsp;this fun &lt;A href="http://channel9.msdn.com/Showpost.aspx?postid=190253"&gt;Channel9&amp;nbsp;video&lt;/A&gt; the other day with Charles Torre and &lt;A HREF="/tims"&gt;Tim Sneath&lt;/A&gt;.&amp;nbsp; In it we talk about some of the fundamentals and architecture of the underlying composition system for Windows Presentation Foundation and for the Desktop Window Manager.&lt;/P&gt;
&lt;P&gt;Just in time for Mother's Day... she'll be so proud :-).&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=594267" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Redirecting GDI, DirectX, and WPF applications</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/05/02/588934.aspx</link><pubDate>Wed, 03 May 2006 08:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:588934</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>32</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/588934.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=588934</wfw:commentRss><description>As mentioned in earlier &lt;A HREF="/greg_schechter/archive/2006/03/25/561167.aspx"&gt;posts&lt;/A&gt;, by far the most important aspect of the DWM is the fact that application windows are redirected to render offscreen, and then the DWM is responsible for compositing those windows to the screen.&amp;nbsp; So, how exactly does that happen?&amp;nbsp; That's what this post is all about.&amp;nbsp; Redirection is a fairly complex topic, but is completely central to the composited desktop.&amp;nbsp; Thanks to Jevan Saks and Greg Swedberg for reviewing this post and answering some of my own questions here as well.
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Before diving into this, I should clarify something that hasn't been brought up in earlier posts: the DWM &lt;I&gt;only&lt;/I&gt; redirects top-level HWNDs.&amp;nbsp; Thus, a Multiple Document Interface (MDI) application (Microsoft Management Console, mmc.exe, is a good example of this) will have its overall top-level HWND, with it's internal child HWNDs, composited as a single entity.&amp;nbsp; The application process draws the child HWNDs, and their non-client areas, as it always has.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;For the purposes of a discussion on redirection, there are really three types of windows that are of interest: GDI-rendered windows, DirectX-rendered windows, and windows rendered by a mix of DirectX and GDI.&amp;nbsp; Let's discuss these in turn.&lt;/P&gt;
&lt;H3&gt;GDI-rendered windows&lt;/H3&gt;
&lt;P&gt;Today and for the near future, &lt;I&gt;most&lt;/I&gt; applications use and will continue to use GDI to render their content.&amp;nbsp; Traditionally, GDI applications were notified when a part of their window became unoccluded, and were asked to repaint that portion of the window.&amp;nbsp; Under the DWM, that window is redirected, and the following happens:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;A system memory surface the size of the window is allocated and associated with that window.&lt;/LI&gt;
&lt;LI&gt;A video memory surface, in the target DirectX pixel format, is allocated, also the size of the window.&lt;/LI&gt;
&lt;LI&gt;When an application retrieves the GDI DC of an HWND, it no longer is the DC of the primary video buffer, as it is in the non-composited, pre-DWM desktop.&amp;nbsp; Instead, the DC is a DC onto the allocated system memory surface.&lt;/LI&gt;
&lt;LI&gt;GDI operations on that DC then populate the system memory surface.&lt;/LI&gt;
&lt;LI&gt;The system, based on a number of variables, decides to update the video memory surface from the system memory surface at the "right times".&lt;/LI&gt;
&lt;LI&gt;The video memory surface is now up-to-date with the application, and the compositor comes around and uses the video memory surface to composite the desktop from.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;There are a few implications of the above that are worth calling out.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;Dual buffers per window&lt;/B&gt; - yes, it's true that GDI windows have both a system memory and a video memory representation.&amp;nbsp; There is without doubt a memory cost to doing this.&amp;nbsp; One obvious alternative is to simply have a video memory representation and have the GDI redirection mechanism render to that format.&amp;nbsp; There are two primary problems with this.&amp;nbsp; The first is that the formats are not the same, and GDI doesn't support rendering into the DirectX format.&amp;nbsp; Even if that were resolved, the more fundamental issue remains.&amp;nbsp; Many GDI operations (XORs, alpha blending, and text are examples) are read-modify-write operations.&amp;nbsp; To do that to a native video memory surface would involve reading back from video memory into the CPU (and thus into system memory), performing the operation, and then writing back.&amp;nbsp; This is typically a horribly slow and pipeline-stalling operation.&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;Minimized windows present a special issue&lt;/B&gt;.&amp;nbsp; Typically when an application receives a minimization, the surface that it's asked to paint is a nominal size, like 130x30, just enough for shades of the non-client area.&amp;nbsp; If the application updates the system memory surface at this point, and we continue our copying to the video memory surface, then any surface we may have had available to us for Flip3D or for thumbnail rendering is suddenly gone.&amp;nbsp; Instead of doing this, we maintain the video memory surface in its last known state, and thus those "secondary window representations" are far more useful when windows are minimized.&amp;nbsp; &lt;/LI&gt;&lt;/UL&gt;
&lt;H3&gt;DirectX-rendered windows&lt;/H3&gt;
&lt;P&gt;Unlike GDI applications, DirectX applications of course can natively render into the DirectX pixel format that the DWM expects.&amp;nbsp; They also have a very clear indication of when they're done rendering due to the requirements that they call Present().&amp;nbsp; As such, DirectX applications only need a single window buffer to manage their redirection.&amp;nbsp; DirectX window redirection is handled by having the DirectX system, when it's determining what surface to provide the app with to render to, make calls to the DWM in order to share a surface between the DirectX client application process, and the DWM process.&amp;nbsp; This "shared surface" support is unique to DirectX atop the WDDM, and is &lt;A HREF="/greg_schechter/archive/2006/04/02/566767.aspx"&gt;another key reason&lt;/A&gt; why WDDM is an absolute requirement for running the DWM.&lt;/P&gt;
&lt;P&gt;When a Present() happens to such a surface, the DWM is notified that there are dirtied surfaces that need to be composited to form the desktop, and that serves as an indication to perform a composition.&amp;nbsp; (It's actually a fair bit more complicated than that, but this description certainly provides the gist of it.)&lt;/P&gt;
&lt;P&gt;Certain DirectX-based applications have much more stringent scheduling requirements (for instance, video applications), and there are public APIs provided that allow the application to get a lot more information, and more control, over when they should render based upon the rendering schedule of the desktop compositor.&amp;nbsp; That will be covered more in a future topic.&lt;/P&gt;
&lt;P&gt;Finally, WPF (Avalon) applications &lt;U&gt;are&lt;/U&gt; DirectX applications, so they render just as the DX applications described above render.&lt;/P&gt;
&lt;H3&gt;Mixed DirectX and GDI Windows&lt;/H3&gt;
&lt;P&gt;The other reasonably common rendering to a top level window involves mixing DirectX and GDI.&amp;nbsp; There are two forms of "mixing" here, one is perfectly fine, and the other is problematic.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The form of mixing that is fine is when there is a window tree of the top level HWND and child HWNDs (and further children, etc), where each individual HWND is either rendered by DirectX or by GDI.&amp;nbsp; In this situation, the redirection component of the DWM forms its own "composition tree" where each node in the tree represents a node or a set of "homogenously rendered nodes" in the "window tree" rooted at the top level HWND.&amp;nbsp; Rendering occurs by having each of these render to their own surface, and then compositing this tree of surfaces to the desktop.&amp;nbsp; Thus, mixed DirectX and GDI rendering works well, so long as the boundary between them is at least at the child HWND level.&lt;/P&gt;
&lt;P&gt;The form of mixing that doesn't work well is when an application uses DirectX and GDI to target the same HWND.&amp;nbsp; This has never been a supported scenario with DirectX, but there have been scenarios where it has happened to work.&amp;nbsp; Under the DWM, this is much more problematic, because there can be no guarantee of ordering between the DirectX and the GDI rendering.&amp;nbsp; This is most troublesome when GDI and DirectX are not only rendering to the same HWND, but to overlapping areas of the same HWND.&amp;nbsp; As such, this usage pattern is not supported.&amp;nbsp; Note that there is an alternative that can often work for an application -- DirectX is capable of handing back a DC to a DirectX surface, and applications can perform GDI rendering to that DC.&amp;nbsp; From the DWM's perspective, that DirectX surface remains purely rendered by DirectX, and all is well.&lt;/P&gt;
&lt;H3&gt;Drawing To and Reading From the Screen -- Baaaad!&lt;/H3&gt;
&lt;P&gt;Lastly, since we're on the redirection topic, one particularly dangerous practice is writing to the screen, either through the use of GetDC(NULL) and writing to that, or attempting to do XOR rubber-band lines, etc.&amp;nbsp; There are two big reasons that writing to the screen is bad:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;It's expensive... writing to the screen itself isn't expensive, but it is almost always accompanied by reading from the screen because one typically does read-modify-write operations like XOR when writing to the screen.&amp;nbsp; Reading from the video memory surface is &lt;U&gt;very&lt;/U&gt; expensive, requires synchronization with the DWM, and stalls the entire GPU pipe, as well as the DWM application pipe.&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;It's unpredictable... if you somehow manage to get to the actual primary and write to it, there can be no predictability as to how long what you wrote to the primary will remain on screen.&amp;nbsp; Since the UCE doesn't know about it, it may get cleared in the next frame refresh, or it may persist for a very long time, depending on what else needs to be updated on the screen.&amp;nbsp; (We really don't allow direct writing to the primary anyhow, for that very reason... if you try to access the DirectDraw primary, for instance, the DWM will turn off until the accessing application exits)&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=588934" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>The role of the Windows Display Driver Model in the DWM</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/04/02/566767.aspx</link><pubDate>Sun, 02 Apr 2006 10:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:566767</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>30</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/566767.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=566767</wfw:commentRss><description>&lt;H3&gt;The Problem&lt;/H3&gt;
&lt;P&gt;Ever since the advent of dedicated graphics processors, even old-school graphics processors that only accelerated GDI blits, the way you would program against them would be similar to how you programmed against the main CPU/memory system before there was virtual memory or interruptible/preemptible processes.&amp;nbsp; That is, you'd have to be sure to directly manage all the video memory yourself, and just count on not being able to have your graphics instructions interrupted.&amp;nbsp; Specifically, DirectX applications have always needed to deal with not getting the video memory they need, or deal with "surface lost" messages from video memory that got kicked out for one reason or another.&amp;nbsp; This puts a major burden on the programmer, and, probably even more importantly, makes for a very poor ecosystem for running multiple video-memory resource intensive applications, because their likelihood of cooperating in a sensible way on resource management is virtually nil.&lt;/P&gt;
&lt;P&gt;Well, the DWM is a DirectX application with a couple of unique challenges in this arena:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The memory requirements on the DWM vary widely.&amp;nbsp; That's because they vary directly with the number of windows the user has open, and while there are known typical usage patterns, the user certainly isn't and cannot be limited to N open windows. 
&lt;LI&gt;The DWM operates in an environment where other DirectX applications &lt;U&gt;do&lt;/U&gt; operate.&amp;nbsp; Video playback, WPF applications, windowed games (btw, Vista "inbox" games like Solitaire, etc., are now written in DirectX), etc.&amp;nbsp; In fact, the DWM is responsible for the final presentation of those applications.&amp;nbsp; So it's critical that such DirectX applications "play well together" and play well with the DWM.&amp;nbsp; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The above challenges don't mesh well with the DirectX described in the first paragraph.&lt;/P&gt;
&lt;H3&gt;Enter WDDM&lt;/H3&gt;
&lt;P&gt;It's the Windows Display Driver Model (WDDM, formerly known as LDDM) that makes all of this viable.&amp;nbsp; WDDM is the new DirectX driver model for Windows Vista and beyond.&amp;nbsp; From the perspective of the DWM it does three main things:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Virtualizes video memory. 
&lt;LI&gt;Allows interruptibility of the GPU. 
&lt;LI&gt;Allows DirectX surfaces to be shared across processes.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The surface sharing feature is key for redirection of DirectX applications, but that's the topic of a later post.&amp;nbsp; Here we're going to discuss the first two.&amp;nbsp; There are other motivators for, and certainly a lot more details on the WDDM, but those aren't as immediately relevant to the DWM as what's discussed here.&lt;/P&gt;
&lt;H4&gt;Virtualizing Video Memory&lt;/H4&gt;
&lt;P&gt;With the WDDM, graphics memory is virtualized.&amp;nbsp; This means that just like system memory, if there is a demand for memory and the memory is all allocated, then secondary storage is turned to, and the system manages all the paging algorithms and mechanics for faulting in the secondary storage into the primary storage when it needs to be operated on.&amp;nbsp; In the case of video memory, the primary storage is video memory, and the secondary storage system memory.&lt;/P&gt;
&lt;P&gt;In the event that video memory allocation is required, and both video memory and system memory are full, the WDDM and the overall virtual memory system will then turn to disk for video memory surfaces.&amp;nbsp; This is an extremely unusual case, and the performance would suffer dearly in that case, but the point is that the system is sufficiently robust to allow this to occur and for the application to reliably continue.&lt;/P&gt;
&lt;P&gt;The upshot of all of this is that applications don't need to be greedy to get &lt;I&gt;all&lt;/I&gt; the memory they need, since they won't be guaranteed true video memory anyhow, and they can always be paged out.&amp;nbsp; This brings the goal of a cooperative set of DirectX applications much, much closer to reality.&amp;nbsp; It also means that there are effectively no more "surface lost" messages from DirectX, and no failed allocations.&lt;/P&gt;
&lt;P&gt;From the DWM's perspective, this is all absolutely key because the DWM can and will allocate memory, and those memory allocations will be done in conjunction with allocations for other applications on the system, putting the "right" surfaces into the true video memory, and paging in and out as necessary.&amp;nbsp; Now, naturally, this is a little bit of a naive viewpoint, since this is the first generation of this virtualizer, but we're observing it to be doing quite well, and it will keep improving.&lt;/P&gt;
&lt;H4&gt;Interruptibility of the GPU&lt;/H4&gt;
&lt;P&gt;So, memory's virtualized, that's good, but what about those little computrons that run around the GPU doing stuff?&amp;nbsp; Can one application's GPU commands be preempted by another application?&amp;nbsp; Prior to WDDM, they could not.&amp;nbsp; With WDDM, they can be.&amp;nbsp; This is referred to as WDDM &lt;I&gt;scheduling&lt;/I&gt;, and WDDM arbitrates usage of the GPU, giving computation to the different applications requesting it.&amp;nbsp; In order to do this, WDDM must be able to interrupt a computation going on on the GPU and context switch in a different processes operation.&amp;nbsp; WDDM defines two levels of interruptibility to support this.&amp;nbsp; &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Basic Scheduling - this is the granularity of scheduling achievable in DirectX 9 class WDDM drivers and hardware, and means that an individual primitive and an individual shader program cannot be interrupted, and must run to completion before a context switch. 
&lt;LI&gt;Advanced Scheduling - this is achievable in DirectX 10 class WDDM drivers and hardware, and here the GPU can be interrupted within an individual primitive and within an individual shader program, leading to much finer-grained preemptability.&amp;nbsp; Note that while DX10 supports advanced scheduling, it's &lt;EM&gt;not&lt;/EM&gt; a requirement for DX10 -- that is, only certain hardware will support it.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The Desktop Window Manager uses DirectX 9, and thus Basic Scheduling.&amp;nbsp; So it's possible that an application that makes errant use of the GPU and uses complex shader programs across large primitives can potentially glitch the DWM.&amp;nbsp; We have yet to see such applications, but there no doubt will be some that either do this unintentionally&amp;nbsp;or are built specifically to do this.&amp;nbsp; Nonetheless, we don't believe that this will be a common issue.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=566767" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>Desktop Window Manager Index of Post Topics</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/03/25/561167.aspx</link><pubDate>Sun, 26 Mar 2006 08:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:561167</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/561167.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=561167</wfw:commentRss><description>Here's a list of topics that I have posted on (with active links) or expect to post on (without links) related to the Desktop Window Manager in Windows Vista. 
&lt;P&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/03/05/544314.aspx"&gt;Under the Hood of the Desktop Window Manager&lt;/A&gt; -- a technical introduction (and &lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/03/10/549310.aspx"&gt;response to comments&lt;/A&gt;) 
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/03/19/555087.aspx"&gt;DWM's use of DirectX, GPUs, and hardware acceleration&lt;/A&gt; (and &lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/03/25/561110.aspx"&gt;response to comments&lt;/A&gt;) 
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/04/02/566767.aspx"&gt;The role of the Windows Display Driver Model in the DWM&lt;/A&gt; (and &lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/04/20/580417.aspx"&gt;response to comments&lt;/A&gt;) 
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/05/02/588934.aspx"&gt;Redirecting GDI, DirectX, and WPF applications&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/06/09/623566.aspx"&gt;How underlying WPF concepts and technology are being used in the DWM&lt;/A&gt;&amp;nbsp; 
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/08/07/690704.aspx"&gt;High DPI support &lt;/A&gt;(and &lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/09/14/753467.aspx"&gt;response to comments&lt;/A&gt;)
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/greg_schechter/archive/2006/09/14/753605.aspx"&gt;APIs in the Desktop Window Manager&amp;nbsp;&lt;/A&gt;
&lt;LI&gt;Rendering and visibility optimizations 
&lt;LI&gt;Memory usage in the DWM 
&lt;LI&gt;Power management and battery life 
&lt;LI&gt;How the DWM paints the window frame and other non-client area 
&lt;LI&gt;Remoting, Magnification, and Accessibility under the DWM 
&lt;LI&gt;Best practices for applications under the DWM&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If there are specific other topics you're interested in, please comment away.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=561167" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>Responding to Comments from "DWM's use of DirectX, GPUs, and hardware acceleration"</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/03/25/561110.aspx</link><pubDate>Sun, 26 Mar 2006 04:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:561110</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/561110.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=561110</wfw:commentRss><description>My earlier post on "&lt;A href="/greg_schechter/archive/2006/03/19/555087.aspx"&gt;DWM's use of DirectX, GPUs, and hardware acceleration&lt;/A&gt;" generated some good comments and questions.&amp;nbsp; I'll use this post to respond. 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;dzCepheus&lt;/I&gt;&lt;/B&gt; wonders about end users and developers creating their own effects, for instance, mapping window content onto spinning cylinders.&amp;nbsp; This is definitely something that we've thought about, and are going to look into extensibility in these directions in a future release, but for Windows Vista, this level of extensibility isn't possible.&amp;nbsp; What is possible is more limited -- the ability to extend glass/blur into the window, and the ability to manipulate live thumbnails of windows in your own applications.&amp;nbsp; More on that in a future post.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;steamy&lt;/I&gt;&lt;/B&gt; asks about DX8 cards rendering glass, in light of my comments about DX9 in the post.&amp;nbsp; Not sure what DX8 cards worked, or when, but DX9/WDDM drivers are absolutely a requirement, as is PS 2.0 support.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;steamy&lt;/I&gt; &lt;/B&gt;also wonders about software rendering for the DWM.&amp;nbsp; Given the confluence of a) commoditization of sufficiently performing graphics hardware; b) not wanting to overly tax the CPU and take it away from other applications, and the long term power efficiency of doing these operations in the GPU and not the CPU; c) the requirement for pushing around lots of pixels and needing big texture bandwidth; and d) the importance of maintaining focus and executing well on one rendering path without bringing in others -- we opted away from pursuing a software path here.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;Nidonocu&lt;/I&gt;&lt;/B&gt; asks about XGL for Linux desktops.&amp;nbsp; I don't know a great deal about XGL (other than the fact that a &lt;A href="http://docs.sun.com/app/docs/doc/801-6670/6i11gqgsq"&gt;different XGL&lt;/A&gt; used to be &lt;I&gt;the&lt;/I&gt; way of programming 3D on Sun Microsystems machines back when I worked there in the early-90's), but I have seen some of the videos I've seen showing it in action.&amp;nbsp; For Windows Vista, we've really focused on building the composited desktop, and working out all the kinks to allow two decades worth of Windows applications to run well on such a fundamentally different desktop rendering model.&amp;nbsp; The fruits of the composition labor show off in big quality and usability wins for the desktop, and some choice places we leverage composition -- for instance Flip3D, high DPI support, and window thumbnails.&amp;nbsp; Now that this groundwork is laid, we expect to really be able to leverage it quite a bit more moving forward -- but also to do so in a "UI-responsible" way really heeding the advice of our graphics and UI designers.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;GRiNSER&lt;/I&gt;&lt;/B&gt; talks about other animations and transitions in the Vista GUI.&amp;nbsp; Vista animations and transitions are definitely not limited to the DWM.&amp;nbsp; There are definitely some choice ones in Explorer, and there are many many situations where GDI rendering for these does absolutely fine.&lt;/P&gt;
&lt;P&gt;Finally,&lt;B&gt;&lt;I&gt; Princess &lt;/I&gt;&lt;/B&gt;talks about interaction between the DWM's usage of the GPU and other applications.&amp;nbsp; This is going to be the main topic of my next entry on the WDDM.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=561110" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>DWM's use of DirectX, GPUs, and hardware acceleration</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/03/19/555087.aspx</link><pubDate>Sun, 19 Mar 2006 22:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:555087</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>19</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/555087.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=555087</wfw:commentRss><description>For the last few years, both desktop and laptop PCs have been outfitted with increasingly powerful graphics chipsets, including blazingly fast geometry and pixel processing, higher fill rates, and faster and faster bandwidth between system memory and video memory.&amp;nbsp; Further, GPU computational increases has been exceeding Moore's Law for some time, outpacing CPU growth.&amp;nbsp; The beneficiaries of this growth has almost entirely been PC games and the gaming community.&amp;nbsp; However, this processing power has largely sat dormant during typical use of the Windows desktop and typical productity/business/everday applications.
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;One of the key goals of the Desktop Window Manager in Windows Vista is to harness all this spare graphics compute power, and bring it to bear on making the computing experience better for the majority of users who are not gamers, or at least not always gamers.&lt;/P&gt;
&lt;P&gt;In order to do this, the DWM is built upon &lt;A href="http://www.microsoft.com/windows/directx"&gt;Microsoft DirectX&lt;/A&gt;, specifically Direct3D, which is the uniform way that software in the Windows environment talks to graphics hardware.&amp;nbsp; More precisely, the DWM is actually built directly atop a layer we internally call "milcore", and milcore is built directly atop DirectX.&amp;nbsp; (More on milcore in a future post.)&amp;nbsp; But the end result is that Direct3D textures are created that represent the window content and the window frame, and DWM/milcore is responsible for issuing the proper Direct3D calls that result in composing all of the Direct3D textures to form the desktop.&lt;/P&gt;
&lt;P&gt;One specific takeaway from this: the Windows Vista desktop (through the DWM) &lt;I&gt;is&lt;/I&gt; a fullscreen Direct3D application.&lt;/P&gt;
&lt;H3&gt;Fundamentally 3D&lt;/H3&gt;
&lt;P&gt;You may know, though, that in typical usage of Direct3D, one doesn't directly bit-blit textures to a primary surface.&amp;nbsp; This is also true in the DWM.&amp;nbsp; The window contents aren't being asked to paint directly to the desktop surface.&amp;nbsp; Instead, they're being treated as texture maps on a 3D mesh that is being rendered by Direct3D and the graphics hardware.&amp;nbsp; For example, in the case of the standard desktop view, it so happens that the 3D mesh that the textures are being mapped to is a very simple rectangle (actually, two adjacent triangles), representing the client area of the window.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;This is important, because once that's seen as being the case, it's not a far leap at all to understand how the DWM does it's 3D window transitions, or the 3D "Flip3D" view as shown in &lt;A HREF="/greg_schechter/archive/2006/03/05/544314.aspx"&gt;this initial DWM post&lt;/A&gt;.&amp;nbsp; Our window transitions (open, close, minimize, restore), are simply 3D transformations of that rectangle that already exists in 3-space.&amp;nbsp; It would not be much harder to modify any of these transitions to be more complex - for instance to map the window content onto a spinning cylinder for minimize.&amp;nbsp; Thankfully we have a crack team of graphic and UI designers that prevent us from making such UI faux pas.&amp;nbsp; &lt;/P&gt;
&lt;H3&gt;Pixel Shaders for Blur&lt;/H3&gt;
&lt;P&gt;One of the signature looks for Windows Vista is the window border's "glass" look.&amp;nbsp; This look allows one to see through the border to what's behind, but also adds some amount of translucency and also blur to what's behind.&amp;nbsp; From a design perspective, this makes window borders feel less heavy and in-your-face, and let's them more readily do their job without calling attention to themselves.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Translucency is readily achievable in most graphics systems (via the alpha channel) and really isn't such a big deal.&amp;nbsp; However, even though it's not completely transparent, windows borders that &lt;I&gt;only&lt;/I&gt; have translucency do not provide a good UI experience.&amp;nbsp; That's because the content behind the borders is too clear and discernible, and distracts the user from the window they're manipulating.&lt;/P&gt;
&lt;P&gt;Therefore, a key element in the Aero design is the blurring of content behind the "glass" borders, to avoid that content being too clear and discernible.&amp;nbsp; This blur is surprisingly difficult to achieve, and the DWM team has spent a lot of brainpower and effort getting it to where it is:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;First, there is the actual blurring of the underlying content.&amp;nbsp; This is done by a custom PS 2.0 pixel shader.&amp;nbsp; Pixel shaders are small programs that run directly on the GPU, which acts essentially as a &lt;A href="http://en.wikipedia.org/wiki/SIMD"&gt;SIMD&lt;/A&gt; machine able to process many pixels in parallel.&lt;/LI&gt;
&lt;LI&gt;The source of the blurring must be a partially composited desktop - everything behind the window border that's being rendered, but not the window border or what's in front of it.&amp;nbsp; And that needs to be pulled out into a different buffer.&lt;/LI&gt;
&lt;LI&gt;Next, the way blur works is by taking neighboring pixels and averaging them together to create a resultant pixel.&amp;nbsp; This means that when a window with "glass" moves, it's not sufficient to just re-render what's behind it.&amp;nbsp; The area re-rendered needs to be extended out a little bit (by the radius of the blur).&amp;nbsp; Without care, this extension can accumulate across multiple windows and lead to invalidating larger and larger portions of the screen.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;All of these combine to create the smooth, seamless blur that Aero glass exhibits; and does so smoothly and quickly so the user doesn't perceive any hiccups on window motion or when "glass" is in front of updating scenes, like video playing.&lt;/P&gt;
&lt;H3&gt;Flipping and Tearing&lt;/H3&gt;
&lt;P&gt;Modern DirectX applications, on modern DirectX 9 class graphics chipsets (which are a requirement for running the Windows Vista DWM), often use "flipping" in order to present their content.&amp;nbsp; Flipping is when the video card is able to present video memory surface A to the monitor while the application writes to video memory surface B.&amp;nbsp; When the application is done with its update, it schedules a "flip" through DirectX, which is executed at the next monitor vertical blank.&amp;nbsp; When executed, the video card now starts reading out from surface B, and the application is freed to write into surface A.&amp;nbsp; On the next flip, they swap back.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The result of this is that the user perceives exactly what the application wants it to without any of the "tearing" that frequently accompanies applications writing directly to the buffer that's being displayed when a screen refresh happens in the middle of the application's update process.&lt;/P&gt;
&lt;P&gt;The DWM uses exactly this technique to avoid window tearing during refresh, and this results in a much smoother desktop.&lt;/P&gt;
&lt;H3&gt;But Isn't There a Limit to Video Memory?&lt;/H3&gt;
&lt;P&gt;There are limits to how much video memory an application can use, and how much GPU time is available.&amp;nbsp; So how can a general window system operate within these limits when there are no limits on, say, the number of windows that can be opened?&amp;nbsp; Answer: the Windows Display Driver Model (WDDM, aka LDDM) makes all of this viable.&amp;nbsp; How's that?&amp;nbsp; That'll be the topic for my next blog entry on the DWM.&amp;nbsp; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=555087" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>Responding to Comments from "Under the Hood of the DWM"</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/03/10/549310.aspx</link><pubDate>Sat, 11 Mar 2006 09:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:549310</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/549310.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=549310</wfw:commentRss><description>Wow... lots of great interest and comments in my previous post on &lt;A HREF="/greg_schechter/archive/2006/03/05/544314.aspx"&gt;"Under the Hood of the Desktop Window Manager"&lt;/A&gt;.&amp;nbsp; Rather than attempting to comment inline, I figured I'd try to address in a separate post.&amp;nbsp; So here goes: 
&lt;P&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;Anonymous&lt;/B&gt;&lt;/I&gt;:&lt;I&gt;&lt;B&gt; &lt;/B&gt;I'd like to know why DWM can't just use the alpha channel of the buffer that Avalon draws to, to be able to do completely hardware accelerated irregular shaped and alpha blended windows, but instead has to drop Avalon HW acceleration and go to software rendering... &lt;/I&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The above is not the case, if I'm parsing correctly.&amp;nbsp; An Avalon application is effectively a DirectX application, and renders to a DirectX surface.&amp;nbsp; This can be a video memory, hardware accelerated surface, and its display through the DWM does &lt;I&gt;not&lt;/I&gt; require that it be booted out to software.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;Stephane Rodriguez:&lt;/B&gt; "Tear free experience" &lt;BR&gt;&lt;BR&gt;How is this possible? Doesn't this depend on how much is getting drawn? &lt;BR&gt;&lt;BR&gt;Two decades ago, on machines like Atari ST and Amiga, it was all about the vertical blank. People used to write applications (demo) that would draw based on the vertical blank frequency, avoid the drawing spot, resulting in smooth scrollers and so on. Whatever happened to this? &lt;BR&gt;&lt;BR&gt;In other words, I don't think the tear experience scales well if you drawing too much on the screen at the same time, say you are running a couple videos concurrently. &lt;BR&gt;&lt;BR&gt;And I still fail to see how tear-free experience will make mom and dad feel excited about Windows Vista. Sorry, it had to be said. &lt;/I&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Today's "tear free" isn't the old Atari/Amiga approach which as you say tried to fit everything into vblank.&amp;nbsp; Instead, DirectX is able to maintain a "flip chain" of buffers and swap between them for what's displayed on the screen.&amp;nbsp; The "flip" happens at a very low level in the system and does occur during vblank.&amp;nbsp; But it doesn't require drawing.&amp;nbsp; The video card then simply scans out the new front buffer, and treats the old front buffer as the back buffer that the application (in this case the DWM) renders into.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Tear-free making Mom &amp;amp; Dad excited about Windows Vista?&amp;nbsp; Yea, can't help you much there :-), but hopefully the accumulation of all the good stuff across Vista will be enough.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;[3/18/06 - Update - tear-free exciting Mom&amp;amp;Dad.&amp;nbsp; It occurs to me that I may have been too flip in this response.&amp;nbsp; Tear-free on it's own won't excite them, however, this is just one of the many quality improvements being made where the sum of which will lead to just a better, more solid feeling product.&amp;nbsp; &lt;A HREF="/kamvedbrat/archive/2006/03/12/550243.aspx"&gt;Kam VedBrat &lt;/A&gt;also talks&amp;nbsp;about this effect.]&lt;/EM&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;JoeW&lt;/B&gt;: I would like to know more about the public APIs. Specifically I would like to know how Vista's native dialog boxes are rendered (message box, explorer windows etc). Do they still use GDI or do they use an unmanaged composition engine? &lt;/I&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;More on the public APIs in a later posting.&amp;nbsp; However, regarding how dialog boxes are rendered, there's fundamentally no change here.&amp;nbsp; GDI is still used, and the windows redirect through the DWM just like any other GDI application.&amp;nbsp; The primary rendering that the DWM itself is responsible for is the non-client areas of windows.&lt;/P&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;David Larsson&lt;/B&gt; &lt;/I&gt;comments on issues he's hitting with High DPI mode in the latest Vista CTP.&amp;nbsp; I can say that many of those rough edges are being addressed.&lt;/P&gt;
&lt;P&gt;Another &lt;I&gt;&lt;B&gt;David&lt;/B&gt; &lt;/I&gt;asks about memory requirements for DWM given that windows contents are stored.&amp;nbsp; It's definitely the case that there is a larger memory requirement when running the DWM -- but rather than getting further into it, I do expect that to be discussed in a future posting.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;Shawn Oster: &lt;/I&gt;&lt;/B&gt;&lt;I&gt;As I'm reading a few dozen questions come to mind. You hit on some of them in your "upcoming topics" hit list but here are the things that sparked: &lt;BR&gt;&lt;BR&gt;1. How signifigant will hardware acceleration be to Glass? It used to be there was the 2D benchmarks for work apps then the 3D benchmark for the fun things. An amazing game card would often be horrible at having a lot of small Excel/Word/Visual Studio windows open. &lt;BR&gt;&lt;BR&gt;2. One of the first things new developers learn is to do their own screen buffering, to a bitmap, metafile, etc. Does the DWM change that since it's already buffering? &lt;BR&gt;&lt;BR&gt;3. What kind of impact will this have on apps like Photoshop? Are there things raster image editing programs can do to improve speed if they are running on Vista? &lt;BR&gt;&lt;BR&gt;4. If you are running old hardward does everything still go through the DWM? Like inside a Virtual PC? &lt;BR&gt;&lt;BR&gt;5. How much control will we have over DWM? For example could someone create Flip/Flip3D as a stand-alone app? The nerdling fun side of my brain imagines interfaces a la Minority Report (minus the gloves and Tom Cruise). &lt;BR&gt;&lt;BR&gt;6. Hmm, speaking of the Minority Report UI, how well will video drag? &lt;BR&gt;&lt;BR&gt;7. How heavy a load does DWM put on the system? I remember when shell replacements were big (LiteStep, geoShell, Cloud9, etc) and the goal was always reducing load while giving UI goodness. Sounds like DWM could be that as long as it isn't seen as a boat anchor. &lt;BR&gt;&lt;BR&gt;Looking forward to more blog posts on this subject. Try to come up for air just a wee bit more often :) &lt;BR&gt;&amp;nbsp;&lt;/I&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;and answers to those...&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;HW acceleration is a very significant determinant of DWM performance.&amp;nbsp; Particularly video memory transfer rate.&amp;nbsp; Windows Vista will enable the DWM on hardware that's capable of supporting it, and we do expect that to be a wide range of hardware. 
&lt;LI&gt;Application doing screen buffering: I'll address that further down in response to another person's question. 
&lt;LI&gt;The DWM itself doesn't really have substantial impact on apps like Photoshop (other than the buffering issues).&amp;nbsp; There may be other Vista advice they can follow, but I don't have that. 
&lt;LI&gt;Things will go through the DWM if the hardware qualifies, including being sure that a Vista Display Driver Model class graphics hardware is in use.&amp;nbsp; More on that in a future post. 
&lt;LI&gt;More on that in a discussion on DWM APIs 
&lt;LI&gt;I assume you're referring to the issue on XP and before that when you drag a window with video, the video lags the window.&amp;nbsp; That's because in those systems, hardware overlays are being used.&amp;nbsp; In Vista, the window is composited, and everything is in sync, so no more lag. 
&lt;LI&gt;We're working hard to be sure that the DWM doesn't put an overly hefty load on the systems that qualify for DWM.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;DCMonkey&lt;/I&gt;&lt;/B&gt; asks about resize semantics under the DWM.&amp;nbsp; This is something we're working on improving, and have made good progress there.&lt;/P&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;Kirill Osenkov&lt;/B&gt; &lt;/I&gt;asks: &lt;I&gt;Does it mean I should get rid of my (now unnecessary) custom back buffer when I port my app to Vista? Does it also mean that all flickering applications will automatically become flicker-free? &lt;/I&gt;&lt;/P&gt;
&lt;P&gt;Yes and No.&amp;nbsp; Applications no longer need to double buffer when the DWM is running provided that their purpose in double buffering was to avoid video-system induced tearing.&amp;nbsp; However, double buffering is also frequently used by applications to avoid "structural tearing" -- for instance, being sure that this triangle and this rectangle are presented atomically.&amp;nbsp; This is not something that the DWM can help with.&amp;nbsp; So it really depends on your usage of double buffering, and your original source of flickering.&amp;nbsp; Each application author is going to need to evaluate that for themselves.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;HTK&lt;/I&gt;&lt;/B&gt; asks whether the first screenshot with the bigger buttons is a real screenshot.&amp;nbsp; No, it's not, sorry I wasn't more clear.&amp;nbsp; That was really intended to show the design element/sensibility for Aero.&amp;nbsp; All the other Windows Vista images are screenshots.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;Chris Nahr&lt;/I&gt;&lt;/B&gt; asks about getting rid of traditional WM_PAINT processing altogether, and just drawing new elements as required.&amp;nbsp; This is absolutely not the direction that this is going.&amp;nbsp; WM_PAINT is still used in many places throughout the system for invalidation and rendering requests of client areas.&amp;nbsp; Chris also asked about higher resolutions.&amp;nbsp; That'll be covered in a future post on high DPI support.&lt;/P&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;ion&lt;/B&gt; &lt;/I&gt;and other asked about jaggies/aliasing in Flip3D.&amp;nbsp; Yes, this is certainly a known issue that we're actively working on addressing.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;Eli&lt;/I&gt;&lt;/B&gt; asks about glass blurring, and DWM accelerating GDI.&amp;nbsp; Pixel shaders are indeed used for the blurring component of the "glass" look.&amp;nbsp; And DWM does &lt;I&gt;not&lt;/I&gt; accelerate GDI rendering.&amp;nbsp; However, due to the nature of desktop composition, operations like window moves and resizes can be faster/more responsive because underlying content need not be re-rendered.&lt;/P&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;Anonymous&lt;/B&gt; &lt;/I&gt;asks about text rendering.&amp;nbsp; The caption area text rendering is going through the same text rendering that WPF uses, and thus is subpixel ClearType.&amp;nbsp; Furthermore, there is an exposed API in the theming DLL for rendering text atop "client area glass" -- more on that in a future post.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;ping pong&lt;/I&gt;&lt;/B&gt; asks if DWM is written in a managed language.&amp;nbsp; It is not.&amp;nbsp; It uses the same unmanaged rendering component that the WPF/Avalon system does.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;Mike Dimmick&lt;/I&gt;&lt;/B&gt; talks about running Java applets in Sun's JRE results in the DWM being disabled.&amp;nbsp; Yes, Sun is well aware of this and is proactively working on a fix.&amp;nbsp; And you're right, that locking the DirectDraw primary surface has this result, since the desktop now needs exclusive access to the DDraw primary for the DWM to work.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;DGC &lt;/I&gt;&lt;/B&gt;asks about memory usage.&amp;nbsp; Yes, there is a larger memory footprint with the DWM.&amp;nbsp; More on that in a future post.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;KJK::Hyperion&lt;/I&gt;&lt;/B&gt; asks about total abuse of this technology through 3rd party programmability.&amp;nbsp; But of course &lt;FONT face="Times New Roman"&gt;☺&lt;/FONT&gt;.&amp;nbsp; We do have a certain amount of programmability of various key features like glass, thumbnails, and control of composition.&amp;nbsp; More on that in a future post.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;I&gt;Keith Patrick&lt;/I&gt;&lt;/B&gt; and &lt;B&gt;&lt;I&gt;MueMeister &lt;/I&gt;&lt;/B&gt;both wonder about the relationship between DWM and WPF, and if there is any.&amp;nbsp; There most definitely is a big relationship.&amp;nbsp; Both DWM and WPF are written on the same unmanaged rendering layer that sits above DirectX and is responsible for all the actual rendering in both WPF and DWM.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=549310" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item><item><title>Under the Hood of the Desktop Window Manager</title><link>http://blogs.msdn.com/greg_schechter/archive/2006/03/05/544314.aspx</link><pubDate>Mon, 06 Mar 2006 09:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:544314</guid><dc:creator>Greg Schechter</dc:creator><slash:comments>74</slash:comments><comments>http://blogs.msdn.com/greg_schechter/comments/544314.aspx</comments><wfw:commentRss>http://blogs.msdn.com/greg_schechter/commentrss.aspx?PostID=544314</wfw:commentRss><description>I've made a grand total of &lt;I&gt;one&lt;/I&gt; post in about the last 21 months.&amp;nbsp; What have I been doing during this time?&amp;nbsp; Why, working on the new Desktop Window Manager for Windows Vista, of course!&amp;nbsp; The Desktop Window Manager (DWM) is one of the more visible features and changes to Windows coming out with the upcoming Windows Vista release. 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Does this mean that I've abandoned Windows Presentation Foundation (Avalon) to work on the DWM?&amp;nbsp; By no means.&amp;nbsp; The DWM is built upon the core graphics layer of Avalon, and is being developed by the same team responsible for Avalon.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;We've been heads down on design, development, and testing for quite some time, but now that there's an end in sight, I figured I'd come up for air and describe a bit about what we've done and the technical underpinnings of this visible feature.&amp;nbsp; There's lots and lots that can potentially be discussed, so I'm going to keep this first post fairly broad and high level, and will be interested in feedback if there are other specific areas of interest that readers would like to delve further into.&amp;nbsp; So please do comment with your thoughts!&lt;/P&gt;
&lt;H3&gt;The public face of the Desktop Window Manager&lt;/H3&gt;
&lt;P&gt;The DWM is of course just part of Windows Vista and not considered distinct from it.&amp;nbsp; Its features are exclusively available in the &lt;A href="http://www.microsoft.com/windowsvista/features/default.mspx"&gt;Windows Vista Aero experience&lt;/A&gt;.&amp;nbsp; I'm pulling out some of the more recognizable features here.&lt;/P&gt;
&lt;TABLE id=table1 cellSpacing=0 cellPadding=0 width=637 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width=258&gt;This is "Aero Glass", the semi-transparent look that Aero provides, with the blurry content behind the window frames, designed to allow the user to focus on the window itself, and not on what lies behind. 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;IMG src="http://static.flickr.com/56/117315234_18c26c9baa_o.png" border=0&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width=258&gt;Here are the live thumbnail views provided on the Windows Vista taskbar. 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;IMG src="http://static.flickr.com/19/117896014_2962f76733_o.jpg" border=0&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width=258&gt;And here are Windows Flip and Windows Flip3D -- the updated Windows Vista experiences invoked by Alt-Tab and Windows-Tab, respectively, for navigating between and selecting windows. 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;IMG src="http://static.flickr.com/47/117896012_3d6f020476_o.jpg" border=0&gt; 
&lt;P&gt;&lt;IMG src="http://static.flickr.com/44/117896013_725edd60b7_o.jpg" border=0&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;H3&gt;Desktop Composition&lt;/H3&gt;
&lt;P&gt;By far the largest change to Windows Vista in the way that windows are presented is the introduction of "desktop composition".&amp;nbsp; This underlies &lt;I&gt;everything&lt;/I&gt; that is done by the DWM.&amp;nbsp; The primary takeaway for desktop composition:&amp;nbsp; the way an application gets pixels on the screen has &lt;I&gt;fundamentally changed&lt;/I&gt;.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;In all versions of Windows, up until Windows XP, applications were asked by Windows to paint their visible region, and they would paint directly to the buffer that was to be displayed by the video card.&amp;nbsp; With Windows Vista, applications are asked by Windows to paint their entire surface to an offscreen surface (alternatively known as a bitmap, buffer, or texture), and it's up to the DWM to take all of these offscreen surfaces, and "compose" them together to the onscreen buffer.&lt;/P&gt;
&lt;P&gt;Read the previous paragraph again.&amp;nbsp; From a windowing system display perspective, this has profound implications in terms of the features that can be implemented, and the quality that can be achieved.&amp;nbsp; Some examples:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;Access to windows&lt;/B&gt; - now that applications are rendered offscreen, those offscreen representations can be used in other places.&amp;nbsp; This is precisely how the Flip, Flip3D, and thumbnail features work, and other features can be built that take advantage of this as well.&lt;BR&gt;&amp;nbsp; 
&lt;LI&gt;&lt;B&gt;Don't involve background applications in window operations&lt;/B&gt; - when a window moves across the screen in XP and before, the portions of background windows that are newly visible only get painted when the background application wakes up and starts painting (in response to WM_PAINT messages it receives when the top window is moving).&amp;nbsp; For non-responsive background applications, or even responsive ones that happen to be paged out, this can yield a &lt;U&gt;very&lt;/U&gt; poor user experience.&amp;nbsp; &lt;BR&gt;&lt;BR&gt;Consider moving an 'Paint' program window over an IE window.&amp;nbsp; On XP and before, the following symptoms are unfortunately all too common:&lt;BR&gt;&lt;BR&gt;&lt;IMG src="/photos/greg_schechter/images/544305/original.aspx" border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG src="/photos/greg_schechter/images/544306/original.aspx" border=0&gt;&lt;BR&gt;&lt;BR&gt;In both of these cases, the underlying Internet Explorer application was unable to repaint itself quick enough to avoid the "trails" that the moving Paint window left behind.&amp;nbsp; &lt;BR&gt;&lt;BR&gt;Under Windows Vista, this simply isn't the case -- underlying windows do not receive WM_PAINTs and are not asked to re-render, since their content is already available to the DWM and is used to composite the screen.&lt;BR&gt;&amp;nbsp; 
&lt;LI&gt;&lt;B&gt;Tear free experience&lt;/B&gt; - given that the DWM orchestrates all rendering to the screen, the latest technologies provided by DirectX that are typically used for games can be used for the overall desktop experience.&amp;nbsp; In particular, graphics cards' ability to "flip" the front buffer results in an absolutely tear free experience as windows are moved around the screen, increasing the smoothness and quality of the user experience.&lt;BR&gt;&amp;nbsp; 
&lt;LI&gt;&lt;B&gt;High resolution support &lt;/B&gt;- the majority of applications out there are agnostic of the monitor resolution (DPI) that they're running at.&amp;nbsp; On the increasingly popular higher resolution monitors (120 DPI, 144 DPI, and beyond), this can produce a bad experience where applications appear very small in physical space.&amp;nbsp; Because the DWM has access to offscreen representation of the application window, the DWM is in a unique position to scale such DPI-unaware applications for their final presentation to the user, making for a much improved experience on the higher resolution monitor. &lt;/LI&gt;&lt;/UL&gt;
&lt;H3&gt;Possible Future Topics&lt;/H3&gt;
&lt;P&gt;Desktop composition is the most fundamental aspect of what the DWM provides, but we've really only scratched the surface of that topic, and there are still a lot of related topics to explore for a full understanding of what we're doing in Windows Vista.&amp;nbsp; Here's a rough cut of likely topics, roughly in the order I'd expect to tackle them.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;DWMs use of DirectX, GPUs, and hardware acceleration 
&lt;LI&gt;The importance and impact of the Windows Vista Display Driver Model to the DWM 
&lt;LI&gt;Redirecting GDI and DirectX applications 
&lt;LI&gt;How underlying WPF concepts and technology are being used 
&lt;LI&gt;How the DWM paints the window frame and other non-client area 
&lt;LI&gt;Remoting, Magnification, and Accessibility under the DWM 
&lt;LI&gt;High DPI support 
&lt;LI&gt;Publicly exposed DWM APIs 
&lt;LI&gt;Rendering and visibility optimizations 
&lt;LI&gt;Memory usage in the DWM &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Again, please do comment with your interests and where you'd like this conversation to go.&amp;nbsp; No promises of course that we'll even get to any of them... but I do expect to.&lt;/P&gt;
&lt;H3&gt;Other DWM-related Sources of Information&lt;/H3&gt;
&lt;P&gt;While this is probably the most technically comprehensive discussion thus far of the DWM out on the web (though I'm certainly happy to be proven wrong), there are definitely other places with great sources of information and news:&amp;nbsp; &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;My ever-esteemed colleague Kam VedBrat maintains a &lt;A href="/kamvedbrat/"&gt;blog&lt;/A&gt; that often gives a great inside perspective about the DWM, specific DWM features, and Windows Vista Aero.&amp;nbsp; 
&lt;LI&gt;The &lt;B&gt;microsoft.public.windows.developer.winfx.aero&lt;/B&gt; newsgroup carries discussion of all things Aero &lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=544314" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/greg_schechter/archive/tags/DWM/default.aspx">DWM</category></item></channel></rss>