Desktop Window Manager: Difference between revisions
Zackmann08 (talk | contribs) |
KMaster888 (talk | contribs) update linking |
||
(35 intermediate revisions by 26 users not shown) | |||
Line 1: | Line 1: | ||
{{short description|Window manager}} |
|||
{{For|the [[X Window System]] window manager|dwm}} |
{{For|the [[X Window System]] window manager|dwm}} |
||
{{multiple issues| |
|||
{{Primary sources|date=March 2010}} |
{{Primary sources|date=March 2010}} |
||
{{Update|date=February 2015}}{{Infobox software |
{{Update|date=February 2015}} |
||
}} |
|||
{{Infobox software |
|||
| name = Desktop Window Manager |
| name = Desktop Window Manager |
||
| screenshot_size = 300px |
| screenshot_size = 300px |
||
| |
| developer = [[Microsoft]] |
||
| released = {{Start date and age|2006|11|30}} |
|||
| service_name = UxSms<ref group=note>As of [[Windows 8]], where DWM is a required component that must be running at all times, it is no longer a service.</ref> |
|||
| operating system = [[Microsoft Windows]] |
| operating system = [[Microsoft Windows]] |
||
}} |
}} |
||
'''Desktop Window Manager''' ('''DWM''', previously '''Desktop Compositing Engine''' or '''DCE''') is the [[window manager]] in [[ |
'''Desktop Window Manager''' ('''DWM''', previously '''Desktop Compositing Engine''' or '''DCE''') is the [[compositing window manager]] in [[Microsoft Windows]] since [[Windows Vista]] that enables the use of [[hardware acceleration]] to render the [[graphical user interface]] of Windows. |
||
It was originally created to enable portions of the new "[[Windows Aero]]" user experience, which allowed for effects such as transparency, 3D window switching and more. It is also included with [[Windows Server 2008]], but requires the "Desktop Experience" feature and compatible graphics drivers to be installed.<ref>{{cite web |
It was originally created to enable portions of the new "[[Windows Aero]]" user experience, which allowed for effects such as transparency, 3D window switching and more. It is also included with [[Windows Server 2008]], but requires the "Desktop Experience" feature and compatible graphics drivers to be installed.<ref>{{cite web |
||
Line 13: | Line 19: | ||
| title=How to enable Windows Vista user experience features on a computer that is running Windows Server 2008 (MSKB947036) |
| title=How to enable Windows Vista user experience features on a computer that is running Windows Server 2008 (MSKB947036) |
||
| date=January 15, 2008 |
| date=January 15, 2008 |
||
| |
| access-date=2008-04-21 |
||
| work=Knowledge Base |
| work=Knowledge Base |
||
| publisher=Microsoft |
| publisher=Microsoft |
||
Line 19: | Line 25: | ||
==Architecture== |
==Architecture== |
||
The Desktop Window Manager is a [[compositing window manager]] |
The Desktop Window Manager is a [[compositing window manager]], meaning that each program has a buffer that it writes data to; DWM then [[Compositing|composites]] each program's buffer into a final image. By comparison, the [[stacking window manager]] in [[Windows XP]] and earlier (and also Windows Vista and Windows 7 with Windows Aero disabled) comprises a single display buffer to which all programs write. |
||
DWM works in different ways depending on the operating system (Windows 7 or Windows Vista) and on the version of the graphics drivers it uses ([[Windows Display Driver Model|WDDM]] 1.0 or 1.1). |
DWM works in different ways depending on the operating system (Windows 7 or Windows Vista) and on the version of the graphics drivers it uses ([[Windows Display Driver Model|WDDM]] 1.0 or 1.1). |
||
Under Windows 7 and with WDDM 1.1 drivers, DWM only writes the program's buffer to the video RAM, even if it is a [[graphics device interface]] (GDI) program. This is because Windows 7 supports (limited) hardware acceleration for GDI<ref>http://blogs.msdn.com/e7/archive/2009/04/25/engineering-windows-7-for-graphics-performance.aspx</ref> and in doing so does not need to keep a copy of the buffer in system RAM so that the CPU can write to it. |
Under Windows 7 and with WDDM 1.1 drivers, DWM only writes the program's buffer to the video RAM, even if it is a [[graphics device interface]] (GDI) program. This is because Windows 7 supports (limited) hardware acceleration for GDI<ref>{{cite web|url=http://blogs.msdn.com/e7/archive/2009/04/25/engineering-windows-7-for-graphics-performance.aspx|title = Engineering Windows 7| date=25 September 2024 }}</ref> and in doing so does not need to keep a copy of the buffer in system RAM so that the CPU can write to it. |
||
Because the compositor has access to the graphics of all applications, it easily allows visual effects that string together visuals from multiple applications, such as transparency. DWM uses [[DirectX |
Because the compositor has access to the graphics of all applications, it easily allows visual effects that string together visuals from multiple applications, such as transparency. DWM uses [[DirectX]] to perform the function of compositing and rendering in the GPU, freeing the CPU of the task of managing the rendering from the [[off-screen buffer]]s to the display. However, it does not affect applications painting to the off-screen buffers – depending on the technologies used for that, this might still be CPU-bound. DWM-agnostic rendering techniques like [[Graphics Device Interface|GDI]] are redirected to the buffers by rendering the [[Graphical user interface|user interface]] (UI) as [[bitmap]]s. DWM-aware rendering technologies like [[Windows Presentation Foundation|WPF]] directly make the internal data structures available in a DWM-compatible format. The window contents in the buffers are then converted to DirectX textures. |
||
The desktop itself is a full-screen [[Direct3D]] surface, with windows being represented as a mesh consisting of two adjacent (and mutually |
The desktop itself is a full-screen [[Direct3D]] surface, with windows being represented as a mesh consisting of two adjacent (and mutually inverted) triangles, which are transformed to represent a 2D rectangle. The texture, representing the UI chrome, is then mapped onto these rectangles. Window transitions are implemented as transformations of the meshes, using [[shader]] programs.<ref name="dwmndirectx">{{cite web |
||
| url = http://blogs.msdn.com/greg_schechter/archive/2006/03/19/555087.aspx |
| url = http://blogs.msdn.com/greg_schechter/archive/2006/03/19/555087.aspx |
||
| title = DWM's use of DirectX, GPU and hardware acceleration |
| title = DWM's use of DirectX, GPU, and hardware acceleration |
||
| author = Greg Schechter |
| author = Greg Schechter |
||
| work = Greg Schechter's Blog |
| work = Greg Schechter's Blog |
||
| publisher = MSDN Blogs |
| publisher = MSDN Blogs |
||
| |
| access-date = 2007-10-14 |
||
}}</ref> With Windows Vista, the transitions are limited to the set of built-in shaders that implement the transformations. Greg Schechter, a developer at Microsoft has suggested that this might be opened up for developers and users to plug in their own effects in a future release.<ref>{{cite web |
}}</ref> With Windows Vista, the transitions are limited to the set of built-in shaders that implement the transformations. Greg Schechter, a developer at Microsoft has suggested that this might be opened up for developers and users to plug in their own effects in a future release.<ref>{{cite web |
||
| url = http://blogs.msdn.com/greg_schechter/archive/2006/03/25/561110.aspx |
| url = http://blogs.msdn.com/greg_schechter/archive/2006/03/25/561110.aspx |
||
Line 39: | Line 45: | ||
| work = Greg Schechter's Blog |
| work = Greg Schechter's Blog |
||
| publisher = MSDN Blogs |
| publisher = MSDN Blogs |
||
| |
| access-date = 2008-04-20 |
||
}}</ref> DWM only maps the primary [[Object Manager (Windows)|desktop object]] as a 3D surface; other desktop objects, including virtual desktops as well as the ''secure desktop'' used by [[User Account Control]] are not.<ref>{{cite web |
}}</ref> DWM only maps the primary [[Object Manager (Windows)|desktop object]] as a 3D surface; other desktop objects, including virtual desktops as well as the ''secure desktop'' used by [[User Account Control]] are not.<ref>{{cite web |
||
| url = http://blogs.msdn.com/cjacks/archive/2006/11/09/a-desktop-of-your-own.aspx |
| url = http://blogs.msdn.com/cjacks/archive/2006/11/09/a-desktop-of-your-own.aspx |
||
Line 46: | Line 52: | ||
| work = Chris Jackson's Semantic Consonance |
| work = Chris Jackson's Semantic Consonance |
||
| publisher = MSDN Blogs |
| publisher = MSDN Blogs |
||
| |
| access-date = 2007-10-14 |
||
}}</ref> |
}}</ref> |
||
[[Image:Vista Flip 3d.png|thumb|right| |
[[Image:Vista Flip 3d.png|thumb|right|Aero Flip demonstrates multiple features of DWM: 3D transformation of 2D planes, scaling and translating the planes to a different position, embedding dynamic views of one application in another and use of custom [[shader]] programs.]] |
||
[[File:Windows7 flip.png|thumb|right| |
[[File:Windows7 flip.png|thumb|right|Aero Flip feature being used in [[Windows 7]]]] |
||
Because all applications render to an off-screen buffer, they can be read off the buffer embedded in other applications as well. Since the off-screen buffer is constantly updated by the application, the embedded rendering will be a dynamic representation of the application window and not a static rendering. This is how the live thumbnail previews and [[ |
Because all applications render to an off-screen buffer, they can be read off the buffer embedded in other applications as well. Since the off-screen buffer is constantly updated by the application, the embedded rendering will be a dynamic representation of the application window and not a static rendering. This is how the live thumbnail previews and [[Windows Flip]] work in [[Windows Vista]] and [[Windows 7]]. DWM exposes a public API that allows applications to access these thumbnail representations.<ref name="underhood">{{cite web | url = https://docs.microsoft.com/en-us/archive/blogs/greg_schechter/under-the-hood-of-the-desktop-window-manager |
||
| title = Under the hood of Desktop Window Manager |
| title = Under the hood of Desktop Window Manager |
||
| author = Greg Schechter |
| author = Greg Schechter |
||
| work = Greg Schechter's Blog |
| work = Greg Schechter's Blog |
||
| date = 6 March 2006 |
|||
| publisher = MSDN Blogs |
| publisher = MSDN Blogs |
||
| |
| access-date = 2021-05-27 |
||
}}</ref> The size of the thumbnail is not fixed; applications can request the thumbnails at any size - smaller than the original window, at the same size or even larger - and DWM will scale them properly before returning. |
}}</ref> The size of the thumbnail is not fixed; applications can request the thumbnails at any size - smaller than the original window, at the same size or even larger - and DWM will scale them properly before returning. Aero Flip does not use the public thumbnail APIs as they do not allow for directly accessing the Direct3D textures.<ref>{{cite web|url=http://msdn2.microsoft.com/en-us/library/aa969541.aspx|title=DWM Thumbnail Overview|website=MSDN|archive-url=https://archive.today/20120717154553/http://msdn.microsoft.com/en-us/library/aa969541.aspx|archive-date=17 July 2012}}</ref> Instead, Aero Flip is implemented directly in the DWM engine. |
||
The Desktop Window Manager uses [[Media Integration Layer]] (MIL), the unmanaged compositor which it shares with [[Windows Presentation Foundation]], to represent the windows as ''composition nodes'' in a ''composition tree''. The composition tree represents the desktop and all the windows hosted in it, which are then rendered by MIL from the back of the scene to the front.<ref name="wpfconcepts">{{cite web |
The Desktop Window Manager uses [[Media Integration Layer]] (MIL), the unmanaged compositor which it shares with [[Windows Presentation Foundation]], to represent the windows as ''composition nodes'' in a ''composition tree''. The composition tree represents the desktop and all the windows hosted in it, which are then rendered by MIL from the back of the scene to the front.<ref name="wpfconcepts">{{cite web |
||
Line 65: | Line 72: | ||
| work = Greg Schechter's Blog |
| work = Greg Schechter's Blog |
||
| publisher = MSDN Blogs |
| publisher = MSDN Blogs |
||
| |
| access-date = 2007-10-14 |
||
}}</ref> Since all the windows contribute to the final image, the color of a resultant pixel can be decided by more than one window. This is used to implement effects such as per-pixel transparency. DWM allows custom shaders to be invoked to control how pixels from multiple applications are used to create the displayed pixel. The DWM includes built-in [[Pixel Shader]] 2.0 programs which compute the color of a pixel in a window by averaging the color of the pixel as determined by the window behind it and its neighboring pixels. These shaders are used by DWM to achieve the blur effect in the window borders of windows managed by DWM, and optionally for the areas where it is requested by the application.<ref name="dwmndirectx"/> |
}}</ref> Since all the windows contribute to the final image, the color of a resultant pixel can be decided by more than one window. This is used to implement effects such as per-pixel transparency. DWM allows custom shaders to be invoked to control how pixels from multiple applications are used to create the displayed pixel. The DWM includes built-in [[Pixel Shader]] 2.0 programs which compute the color of a pixel in a window by averaging the color of the pixel as determined by the window behind it and its neighboring pixels. These shaders are used by DWM to achieve the blur effect in the window borders of windows managed by DWM, and optionally for the areas where it is requested by the application.<ref name="dwmndirectx"/> |
||
Line 72: | Line 79: | ||
During full-screen applications, such as games, DWM does not perform window compositing and therefore performance will not appreciably decrease. |
During full-screen applications, such as games, DWM does not perform window compositing and therefore performance will not appreciably decrease. |
||
On Windows 8 and [[Windows Server 2012]], DWM is used at all times and cannot be disabled, due to the new "start screen experience" implemented. Since the DWM process is usually required to run at all times on Windows 8, users experiencing an issue with the process are seeing memory usage decrease after a system reboot. This is often the first step in a long list of troubleshooting tasks that can help. It is possible to prevent DWM from restarting temporarily in Windows 8, which causes the desktop to turn black, the taskbar grey, and break the start screen/modern apps, but desktop apps will continue to function and appear just like Windows 7 and Vista's Basic theme, based on the single-buffer renderer used by XP. They also use Windows 8's centered title bar, visible within [[WinPE|Windows PreInstallation Environment]]. Starting up Windows without DWM will not work because the lock screen requires DWM, so it can only be done on the fly, and does not have any practical purposes. Starting with Windows 10, disabling DWM in such a way will cause the entire compositing engine to break, even traditional desktop apps, due to Universal App implementations in the taskbar and new start menu.{{ |
On Windows 8 and [[Windows Server 2012]], DWM is used at all times and cannot be disabled, due to the new "start screen experience" implemented. Since the DWM process is usually required to run at all times on Windows 8, users experiencing an issue with the process are seeing memory usage decrease after a system reboot. This is often the first step in a long list of troubleshooting tasks that can help. It is possible to prevent DWM from restarting temporarily in Windows 8, which causes the desktop to turn black, the taskbar grey, and break the start screen/modern apps, but desktop apps will continue to function and appear just like Windows 7 and Vista's Basic theme, based on the single-buffer renderer used by XP. They also use Windows 8's centered title bar, visible within [[WinPE|Windows PreInstallation Environment]]. Starting up Windows without DWM will not work because the lock screen requires DWM, so it can only be done on the fly, and does not have any practical purposes. Starting with Windows 10, disabling DWM in such a way will cause the entire compositing engine to break, even traditional desktop apps, due to Universal App implementations in the taskbar and new start menu.{{citation needed|date=October 2016}} Unlike its predecessors, Windows 8 supports basic display adapters through [[Windows Advanced Rasterization Platform]] (WARP), which uses [[software rendering]] and the CPU to render the interface rather than the graphics card. This allows DWM to function without compatible drivers, but not at the same level of performance as with a normal graphics card. DWM on Windows 8 also adds support for [[stereoscopy|stereoscopic 3D]].<ref name=dwm-alwayson>{{cite web|title=Desktop Window Manager is always on|url=http://msdn.microsoft.com/en-us/library/windows/desktop/hh848042%28v=vs.85%29.aspx|work=Windows 8 and Windows Server 2012 Compatibility Cookbook|publisher=MSDN|access-date=4 September 2012}}</ref> |
||
==Redirection== |
==Redirection== |
||
For rendering techniques that are not DWM-aware, output must be redirected to the DWM buffers. With Windows, either [[Graphics Device Interface|GDI]] or [[DirectX]] can be used for rendering. To make these two work with DWM, redirection techniques for both are provided. |
For rendering techniques that are not DWM-aware, output must be redirected to the DWM buffers. With Windows, either [[Graphics Device Interface|GDI]] or [[DirectX]] can be used for rendering. To make these two work with DWM, redirection techniques for both are provided. |
||
With GDI, which is the most used UI rendering technique in [[Microsoft Windows]], each application window is notified when it or a part of it comes in view and it is the job of the application to render itself. Without DWM, the rendering [[raster graphics|rasterizes]] the UI in a buffer in video memory, from where it is rendered to the screen. Under DWM, GDI calls are redirected to use the Canonical Display Driver (cdd.dll), a software |
With GDI, which is the most used UI rendering technique in [[Microsoft Windows]], each application window is notified when it or a part of it comes in view and it is the job of the application to render itself. Without DWM, the rendering [[raster graphics|rasterizes]] the UI in a buffer in video memory, from where it is rendered to the screen. Under DWM, GDI calls are redirected to use the Canonical Display Driver (cdd.dll), a software renderer.<ref>{{cite web |url=http://blogs.msdn.com/b/directx/archive/2009/09/29/comparing-direct2d-and-gdi.aspx |title=Comparing Direct2D and GDI - DirectX Developer Blog |access-date=2014-08-19 |archive-url=https://web.archive.org/web/20140408062122/http://blogs.msdn.com/b/directx/archive/2009/09/29/comparing-direct2d-and-gdi.aspx |archive-date=2014-04-08 |url-status=dead }}</ref> A buffer equal to the size of the window is allocated in system memory and CDD.DLL outputs to this buffer rather than the video memory. Another buffer is allocated in the video memory to represent the DirectX surface, which is used as the texture for the window meshes. The system memory buffer is converted to the DirectX surface separately and kept in sync. This round-about route is required because GDI cannot output directly in DirectX pixel format. The surface is read by the compositor and is composited to the desktop in video memory. Writing the output of GDI to system memory is not hardware accelerated, nor is conversion to the DirectX surface. When a GDI window is minimized, invisible, or visible on the same monitor as a full-screen DirectX application, by limitation of GDI, the GDI bitmap buffer is no longer received by the application when requesting a device context during painting or updating (this can sometimes be seen when a GDI operation copying from one window to another output black or empty regions instead of the expected window content). Thus, DWM uses the last bitmap rendered to the buffer before the application was minimized.<ref name="redir">{{cite web | url = http://blogs.msdn.com/greg_schechter/archive/2006/05/02/588934.aspx | title = Redirecting GDI, DirectX, and WPF applications | access-date = 2007-10-14 | author = Greg Schechter | archive-url = https://web.archive.org/web/20100305172826/http://blogs.msdn.com/greg_schechter/archive/2006/05/02/588934.aspx | archive-date = 2010-03-05 | url-status = dead }}</ref> |
||
Starting from Windows 7, Canonical Display Driver no longer renders to the system memory copy when a WDDM 1.1/DXGI 1.1 compliant video driver is present. |
Starting from Windows 7, Canonical Display Driver no longer renders to the system memory copy when a WDDM 1.1/DXGI 1.1 compliant video driver is present. |
||
For applications using [[DirectX]] to write to a 3D surface, the DirectX implementation in [[Windows Vista]] uses [[Windows Display Driver Model|WDDM]] to share the surface with DWM. DWM then uses the surface directly and maps it |
For applications using [[DirectX]] to write to a 3D surface, the DirectX implementation in [[Windows Vista]] uses [[Windows Display Driver Model|WDDM]] to share the surface with DWM. DWM then uses the surface directly and maps it onto the window meshes. For Windows presentation foundation (WPF) applications (which are DirectX applications), the compositor renders to such shared surfaces which are then composited into the final desktop.<ref name="redir"/> Applications can mix either rendering techniques across multiple child windows, as long as both GDI and DirectX are not used to render the same window. In that case, the ordering between DirectX and GDI rendering cannot be guaranteed, and as such it cannot be guaranteed that the GDI bitmap from the system memory has been translated to the video memory surface. This means that the final composition may not contain the GDI-rendered elements.<ref name="redir"/> To prevent this, DWM is temporarily turned off, as long as an application that mixes GDI and DirectX in the same window is running. |
||
==Hardware requirements== |
==Hardware requirements== |
||
In Windows Vista, DWM requires compatible physical or virtual hardware:<ref>{{cite web|url=http://support.microsoft.com/kb/919183|title=System requirements for Windows Vista |publisher=[[Microsoft]]|date=2007-11-13| |
In Windows Vista, DWM requires compatible physical or virtual hardware:<ref>{{cite web|url=http://support.microsoft.com/kb/919183|title=System requirements for Windows Vista |publisher=[[Microsoft]]|date=2007-11-13|access-date=2009-02-11}}</ref> |
||
*A [[Graphics processing unit|GPU]] that supports the [[Windows Display Driver Model]] (WDDM) |
*A [[Graphics processing unit|GPU]] that supports the [[Windows Display Driver Model]] (WDDM) |
||
*[[Direct3D]] 9 support |
*[[Direct3D]] 9 support |
||
Line 91: | Line 98: | ||
*Passes the Windows Aero acceptance test in the Windows Driver Kit (WDK) |
*Passes the Windows Aero acceptance test in the Windows Driver Kit (WDK) |
||
In Windows 7, the Desktop Window Manager has been reworked to use Direct3D 10.1, but the hardware requirements remain the same as in Windows Vista; Direct3D 9 hardware is supported with the "[[Direct3D |
In Windows 7, the Desktop Window Manager has been reworked to use Direct3D 10.1, but the hardware requirements remain the same as in Windows Vista; Direct3D 9 hardware is supported with the "[[Direct3D Feature levels|10 Level 9]]" layer introduced in the [[Direct3D 11]] runtime. Windows 8 has the same requirements as 7, but it can also use software rendering when compatible video hardware is absent.<ref name=dwm-alwayson/> |
||
[[Hardware virtualization]] software that emulate hardware required for DWM include [[VirtualBox]] 4.1 and later, [[VMware Fusion]] 3.0 and later, and [[VMware Workstation]] 7.0 onwards. In addition, [[Windows Virtual PC]] allows composition using the [[Remote Desktop Protocol]]. |
[[Hardware virtualization]] software that emulate hardware required for DWM include [[VirtualBox]] 4.1 and later, [[VMware Fusion]] 3.0 and later, and [[VMware Workstation]] 7.0 onwards. In addition, [[Windows Virtual PC]] allows composition using the [[Remote Desktop Protocol]]. |
||
==Developer experience== |
|||
Developer functionality related to the Desktop Window Manager is provided within the header file <code>dwmapi.h</code> within the [[Microsoft Windows SDK|Windows SDK]]. |
|||
==See also== |
==See also== |
||
*[[Compiz]] |
*[[Compiz]] |
||
*[[Desktop environment]] |
|||
*[[Mutter (software)|Mutter]] |
|||
*[[Quartz Compositor]] |
|||
==Notes== |
|||
{{Reflist|group=note}} |
|||
==References== |
==References== |
||
Line 106: | Line 122: | ||
*[http://weblogs.asp.net/kennykerr/archive/2006/08/10/Windows-Vista-for-Developers-_1320_-Part-3-_1320_-The-Desktop-Window-Manager.aspx Using the DWM APIs] |
*[http://weblogs.asp.net/kennykerr/archive/2006/08/10/Windows-Vista-for-Developers-_1320_-Part-3-_1320_-The-Desktop-Window-Manager.aspx Using the DWM APIs] |
||
*[http://www.groovypost.com/howto/geek-stuff/what-is-dwm-exe-virus-should-it-be-running What is DWM.exe is it a virus?] |
*[http://www.groovypost.com/howto/geek-stuff/what-is-dwm-exe-virus-should-it-be-running What is DWM.exe is it a virus?] |
||
*[http://fanyit.com/problems-solutions-it/how-to-disable-dwm-exe-or-stop-from-the-startup/ dwm.exe and what is it?] |
|||
{{Windows Components}} |
{{Windows Components}} |
Latest revision as of 14:38, 13 December 2024
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
|
Developer(s) | Microsoft |
---|---|
Initial release | November 30, 2006 |
Operating system | Microsoft Windows |
Service name | UxSms[note 1] |
Desktop Window Manager (DWM, previously Desktop Compositing Engine or DCE) is the compositing window manager in Microsoft Windows since Windows Vista that enables the use of hardware acceleration to render the graphical user interface of Windows.
It was originally created to enable portions of the new "Windows Aero" user experience, which allowed for effects such as transparency, 3D window switching and more. It is also included with Windows Server 2008, but requires the "Desktop Experience" feature and compatible graphics drivers to be installed.[1]
Architecture
[edit]The Desktop Window Manager is a compositing window manager, meaning that each program has a buffer that it writes data to; DWM then composites each program's buffer into a final image. By comparison, the stacking window manager in Windows XP and earlier (and also Windows Vista and Windows 7 with Windows Aero disabled) comprises a single display buffer to which all programs write.
DWM works in different ways depending on the operating system (Windows 7 or Windows Vista) and on the version of the graphics drivers it uses (WDDM 1.0 or 1.1). Under Windows 7 and with WDDM 1.1 drivers, DWM only writes the program's buffer to the video RAM, even if it is a graphics device interface (GDI) program. This is because Windows 7 supports (limited) hardware acceleration for GDI[2] and in doing so does not need to keep a copy of the buffer in system RAM so that the CPU can write to it.
Because the compositor has access to the graphics of all applications, it easily allows visual effects that string together visuals from multiple applications, such as transparency. DWM uses DirectX to perform the function of compositing and rendering in the GPU, freeing the CPU of the task of managing the rendering from the off-screen buffers to the display. However, it does not affect applications painting to the off-screen buffers – depending on the technologies used for that, this might still be CPU-bound. DWM-agnostic rendering techniques like GDI are redirected to the buffers by rendering the user interface (UI) as bitmaps. DWM-aware rendering technologies like WPF directly make the internal data structures available in a DWM-compatible format. The window contents in the buffers are then converted to DirectX textures.
The desktop itself is a full-screen Direct3D surface, with windows being represented as a mesh consisting of two adjacent (and mutually inverted) triangles, which are transformed to represent a 2D rectangle. The texture, representing the UI chrome, is then mapped onto these rectangles. Window transitions are implemented as transformations of the meshes, using shader programs.[3] With Windows Vista, the transitions are limited to the set of built-in shaders that implement the transformations. Greg Schechter, a developer at Microsoft has suggested that this might be opened up for developers and users to plug in their own effects in a future release.[4] DWM only maps the primary desktop object as a 3D surface; other desktop objects, including virtual desktops as well as the secure desktop used by User Account Control are not.[5]
Because all applications render to an off-screen buffer, they can be read off the buffer embedded in other applications as well. Since the off-screen buffer is constantly updated by the application, the embedded rendering will be a dynamic representation of the application window and not a static rendering. This is how the live thumbnail previews and Windows Flip work in Windows Vista and Windows 7. DWM exposes a public API that allows applications to access these thumbnail representations.[6] The size of the thumbnail is not fixed; applications can request the thumbnails at any size - smaller than the original window, at the same size or even larger - and DWM will scale them properly before returning. Aero Flip does not use the public thumbnail APIs as they do not allow for directly accessing the Direct3D textures.[7] Instead, Aero Flip is implemented directly in the DWM engine.
The Desktop Window Manager uses Media Integration Layer (MIL), the unmanaged compositor which it shares with Windows Presentation Foundation, to represent the windows as composition nodes in a composition tree. The composition tree represents the desktop and all the windows hosted in it, which are then rendered by MIL from the back of the scene to the front.[8] Since all the windows contribute to the final image, the color of a resultant pixel can be decided by more than one window. This is used to implement effects such as per-pixel transparency. DWM allows custom shaders to be invoked to control how pixels from multiple applications are used to create the displayed pixel. The DWM includes built-in Pixel Shader 2.0 programs which compute the color of a pixel in a window by averaging the color of the pixel as determined by the window behind it and its neighboring pixels. These shaders are used by DWM to achieve the blur effect in the window borders of windows managed by DWM, and optionally for the areas where it is requested by the application.[3]
Since MIL provides a retained mode graphics system by caching the composition trees, the job of repainting and refreshing the screen when windows are moved is handled by DWM and MIL, freeing the application of the responsibility. The background data is already in the composition tree and the off-screen buffers and is directly used to render the background. In pre-Vista Windows OSs, background applications had to be requested to re-render themselves by sending them the WM_PAINT
message.[6] DWM uses double-buffered graphics to prevent flickering and tearing when moving windows.[3][6] The compositing engine uses optimizations such as culling to improve performance, as well as not redrawing areas that have not changed.[8] Because the compositor is multi-monitor aware, DWM natively supports this too.[8]
During full-screen applications, such as games, DWM does not perform window compositing and therefore performance will not appreciably decrease.
On Windows 8 and Windows Server 2012, DWM is used at all times and cannot be disabled, due to the new "start screen experience" implemented. Since the DWM process is usually required to run at all times on Windows 8, users experiencing an issue with the process are seeing memory usage decrease after a system reboot. This is often the first step in a long list of troubleshooting tasks that can help. It is possible to prevent DWM from restarting temporarily in Windows 8, which causes the desktop to turn black, the taskbar grey, and break the start screen/modern apps, but desktop apps will continue to function and appear just like Windows 7 and Vista's Basic theme, based on the single-buffer renderer used by XP. They also use Windows 8's centered title bar, visible within Windows PreInstallation Environment. Starting up Windows without DWM will not work because the lock screen requires DWM, so it can only be done on the fly, and does not have any practical purposes. Starting with Windows 10, disabling DWM in such a way will cause the entire compositing engine to break, even traditional desktop apps, due to Universal App implementations in the taskbar and new start menu.[citation needed] Unlike its predecessors, Windows 8 supports basic display adapters through Windows Advanced Rasterization Platform (WARP), which uses software rendering and the CPU to render the interface rather than the graphics card. This allows DWM to function without compatible drivers, but not at the same level of performance as with a normal graphics card. DWM on Windows 8 also adds support for stereoscopic 3D.[9]
Redirection
[edit]For rendering techniques that are not DWM-aware, output must be redirected to the DWM buffers. With Windows, either GDI or DirectX can be used for rendering. To make these two work with DWM, redirection techniques for both are provided.
With GDI, which is the most used UI rendering technique in Microsoft Windows, each application window is notified when it or a part of it comes in view and it is the job of the application to render itself. Without DWM, the rendering rasterizes the UI in a buffer in video memory, from where it is rendered to the screen. Under DWM, GDI calls are redirected to use the Canonical Display Driver (cdd.dll), a software renderer.[10] A buffer equal to the size of the window is allocated in system memory and CDD.DLL outputs to this buffer rather than the video memory. Another buffer is allocated in the video memory to represent the DirectX surface, which is used as the texture for the window meshes. The system memory buffer is converted to the DirectX surface separately and kept in sync. This round-about route is required because GDI cannot output directly in DirectX pixel format. The surface is read by the compositor and is composited to the desktop in video memory. Writing the output of GDI to system memory is not hardware accelerated, nor is conversion to the DirectX surface. When a GDI window is minimized, invisible, or visible on the same monitor as a full-screen DirectX application, by limitation of GDI, the GDI bitmap buffer is no longer received by the application when requesting a device context during painting or updating (this can sometimes be seen when a GDI operation copying from one window to another output black or empty regions instead of the expected window content). Thus, DWM uses the last bitmap rendered to the buffer before the application was minimized.[11]
Starting from Windows 7, Canonical Display Driver no longer renders to the system memory copy when a WDDM 1.1/DXGI 1.1 compliant video driver is present.
For applications using DirectX to write to a 3D surface, the DirectX implementation in Windows Vista uses WDDM to share the surface with DWM. DWM then uses the surface directly and maps it onto the window meshes. For Windows presentation foundation (WPF) applications (which are DirectX applications), the compositor renders to such shared surfaces which are then composited into the final desktop.[11] Applications can mix either rendering techniques across multiple child windows, as long as both GDI and DirectX are not used to render the same window. In that case, the ordering between DirectX and GDI rendering cannot be guaranteed, and as such it cannot be guaranteed that the GDI bitmap from the system memory has been translated to the video memory surface. This means that the final composition may not contain the GDI-rendered elements.[11] To prevent this, DWM is temporarily turned off, as long as an application that mixes GDI and DirectX in the same window is running.
Hardware requirements
[edit]In Windows Vista, DWM requires compatible physical or virtual hardware:[12]
- A GPU that supports the Windows Display Driver Model (WDDM)
- Direct3D 9 support
- Pixel Shader 2.0 support
- Support for 32 bits per pixel
- Passes the Windows Aero acceptance test in the Windows Driver Kit (WDK)
In Windows 7, the Desktop Window Manager has been reworked to use Direct3D 10.1, but the hardware requirements remain the same as in Windows Vista; Direct3D 9 hardware is supported with the "10 Level 9" layer introduced in the Direct3D 11 runtime. Windows 8 has the same requirements as 7, but it can also use software rendering when compatible video hardware is absent.[9]
Hardware virtualization software that emulate hardware required for DWM include VirtualBox 4.1 and later, VMware Fusion 3.0 and later, and VMware Workstation 7.0 onwards. In addition, Windows Virtual PC allows composition using the Remote Desktop Protocol.
Developer experience
[edit]Developer functionality related to the Desktop Window Manager is provided within the header file dwmapi.h
within the Windows SDK.
See also
[edit]Notes
[edit]References
[edit]- ^ "How to enable Windows Vista user experience features on a computer that is running Windows Server 2008 (MSKB947036)". Knowledge Base. Microsoft. January 15, 2008. Retrieved 2008-04-21.
- ^ "Engineering Windows 7". 25 September 2024.
- ^ a b c Greg Schechter. "DWM's use of DirectX, GPU, and hardware acceleration". Greg Schechter's Blog. MSDN Blogs. Retrieved 2007-10-14.
- ^ Greg Schechter. "Responding to Comments from "DWM's use of DirectX, GPU and hardware acceleration"". Greg Schechter's Blog. MSDN Blogs. Retrieved 2008-04-20.
- ^ Chris Jackson. "Desktop Window Manager only runs on the primary desktop". Chris Jackson's Semantic Consonance. MSDN Blogs. Retrieved 2007-10-14.
- ^ a b c Greg Schechter (6 March 2006). "Under the hood of Desktop Window Manager". Greg Schechter's Blog. MSDN Blogs. Retrieved 2021-05-27.
- ^ "DWM Thumbnail Overview". MSDN. Archived from the original on 17 July 2012.
- ^ a b c Greg Schechter. "How underlying WPF concepts and technology are being used in the DWM". Greg Schechter's Blog. MSDN Blogs. Retrieved 2007-10-14.
- ^ a b "Desktop Window Manager is always on". Windows 8 and Windows Server 2012 Compatibility Cookbook. MSDN. Retrieved 4 September 2012.
- ^ "Comparing Direct2D and GDI - DirectX Developer Blog". Archived from the original on 2014-04-08. Retrieved 2014-08-19.
- ^ a b c Greg Schechter. "Redirecting GDI, DirectX, and WPF applications". Archived from the original on 2010-03-05. Retrieved 2007-10-14.
- ^ "System requirements for Windows Vista". Microsoft. 2007-11-13. Retrieved 2009-02-11.