WPF UI Optimization: Identifying the Rendering Tier
Friday, August 3, 2012 Category : DirectX, Hardware Acceleration, Rendering Tier, Software Acceleration, WPF 0
When a WPF application is run, WPF checks the underlying hardware as well as software (read DirectX) to determine the best way of processing everything. So, if DirectX is installed, video buffer settings are as required, graphics card is functional and drivers are installed, WPF uses hardware acceleration for rendering. All the non-rendering processing happens at the CPU level while all the rendering related processing is delegated to the GPU. This is the ideal scenario, in most cases, in which a WPF application performs well.
In some cases though, based on what it finds, the WPF engine reverts to using software rendering, which may not be ideal except in cases where the graphics card is old or if the capabilities are low. In software rendering, the rendering related processing is not performed at the GPU level and is instead performed at the CPU level.
To be able to troubleshoot performance issues with a WPF application, the first question that comes to mind is whether the WPF application actually used the shining graphics card and latest software we put into the system. This can be found out by checking the Rendering Tier being used by the application.
For any WPF application, it is important to log the rendering tier that is being used at the client running the application. Rendering tier can be obtained in C# using the following code:
As per MSDN, System.Windows.Media.RenderCapability.Tier is “An Int32 value whose high-order word corresponds to the rendering tier for the current thread”. So we shift it by 16 bits and get the value.
A detailed explanation of the various rendering Tiers is available here. Though in short:
Rendering Tier 0: No graphics hardware acceleration
Rendering Tier 1: Partial graphics hardware acceleration
Rendering Tier 2: Most graphics features use graphics hardware acceleration
In some cases though, based on what it finds, the WPF engine reverts to using software rendering, which may not be ideal except in cases where the graphics card is old or if the capabilities are low. In software rendering, the rendering related processing is not performed at the GPU level and is instead performed at the CPU level.
To be able to troubleshoot performance issues with a WPF application, the first question that comes to mind is whether the WPF application actually used the shining graphics card and latest software we put into the system. This can be found out by checking the Rendering Tier being used by the application.
For any WPF application, it is important to log the rendering tier that is being used at the client running the application. Rendering tier can be obtained in C# using the following code:
System.Windows.Media.RenderCapability.Tier >> 16
As per MSDN, System.Windows.Media.RenderCapability.Tier is “An Int32 value whose high-order word corresponds to the rendering tier for the current thread”. So we shift it by 16 bits and get the value.
A detailed explanation of the various rendering Tiers is available here. Though in short:
Rendering Tier 0: No graphics hardware acceleration
Rendering Tier 1: Partial graphics hardware acceleration
Rendering Tier 2: Most graphics features use graphics hardware acceleration