Document directory
Plan:
Area: Graphics Title: Rendering
Scenario:
1. Use software rendering
2. Use hardware rendering
3. Iterate
Stress Attack Point: Memory leak-Graphics rendering leaking Failure: Out of memory
Estimated Time: 2010/11/15-2010/11/19
First day (2010/11/15)
Step 1: Material search
1. About DirectXHttp://baike.baidu.com/view/15762.htm
2. WPF Graphics Rendering OverviewHttp://msdn.microsoft.com/zh-cn/library/ms748373.aspx
3. Optimizing Performance: Taking Advantage of HardwareHttp://msdn.microsoft.com/zh-cn/library/bb613578.aspx
4. WPF Performance Analysis ToolHttp://msdn.microsoft.com/zh-cn/library/aa969767 (VS.90). aspx
5. Graphics Rendering Registry Settings
Http://msdn.microsoft.com/zh-cn/library/aa970912.aspx
Main point:
Disable hardware acceleration
Registry Key |
Value Type |
HKEY_CURRENT_USER \ SOFTWARE \ Microsoft \ aveon. Graphics \ DisableHWAcceleration |
DWORD |
UseDisable hardware accelerationTo disable hardware acceleration for debugging and testing purposes. When you see a rendering project in the application, try to disable hardware acceleration. If the project disappears, the video driver may be faulty.
"Disable hardware acceleration options"Is a DWORD value equal to 0 or 1. If the value is 1, hardware acceleration is disabled. If the system meets the hardware acceleration requirements, the value 0 enables hardware acceleration. For more information, see the graphic presentation layer.
6. How do you determine if WPF is using Hardware or Software Rendering?
Http://stackoverflow.com/questions/149763/how-do-you-determine-if-wpf-is-using-hardware-or-software-rendering
Main point:
Logger. InfoFormat ("WPF Tier = {0}", FIG/0x10000 );
RenderCapability. TierChanged + =
(Sender, args) => logger. InfoFormat ("WPF Tier Changed to {0 }",
RenderCapability. Tier/0x10000 );
7. What's New for Performance in WPF in. NET 4
Http://blogs.msdn.com/ B /jgoldb/archive/2010/04/12/what-s-new-for-performance-in-wpf-in-net-4.aspx
Main point: New API to allow WPF apps to force SW rendering per process
In NET 3.5 SP1 we added new API to allow developers to force software rendering per applicationWindowInstead of using the GPU (see my Performance improvements in WPF in. Net 3.5/3.0 SP1 blog), in NET 4 you can now do so for the entireProcess.
As reported (see here), depending on the machine configuration and the application, software-based rendering is sometimes faster than hardware.
This cocould improve rendering performance for certain scenarios and machines configuration, in most cases Hardware rendering shocould perform better. Please use carefully and verify with your app and machine configuration.
In certain cases apps may want to use Software rendering for reliability reasons, for example on machines (typically older) that do not have reliable drivers.
This APIs shoshould provide developers a much better alternative than setting the global 'Disable HW acceleration' registry key (see
Here)
VS 2010 for example is using this feature to force VS 2010 into Software rendering on VMs thus improving reliability. VS 2010 is doing so since some VMs graphic emulation drivers found VS 2010 is doing so since some VMs graphic emulation drivers found not to be reliable. here is an example for how to use this API:
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
if (WeThinkWeShouldRenderInSoftware())
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
}
}
Notes:
I) The precedence order for software rendering is:
- DisableHWAcceleration reg key
- RenderOptions. ProcessRenderMode (per process)
- HwndTarget. RenderMode (per-target/window)
II) The app force Software rendering at any time, however there is no way to force Hardware rendering back on once it was setSoftwareOnly.
8. System. Windows. Media. RenderCapability. Tier returns not the render mode
Http://stackoverflow.com/questions/3060329/system-windows-media-rendercapability-tier-returns-not-the-render-mode
Main point:
HwndSource hwndSource = PresentationSource.FromVisual(visual) as System.Windows.Interop.HwndSource;
HwndTarget hwndTarget = hwndSource.CompositionTarget;
hwndTarget.RenderMode = renderMode;
9.
RegistryKey Class
Http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.aspx