What is the procedure for disabling hardware acceleration in WPF? What is it exactly? Is it a Windows setting, a Visual Studio setting, or something you alter in the code of your WPF project? Will it affect only the program you're running or will it be system-wide?
-
Does this answer your question? Software rendering mode - WPF – Wai Ha Lee Oct 21 '20 at 10:53
That is a system wide setting, from the desktop, right click to bring up a popup menu, click on properties, and look around in there for the video settings to disable Hardware acceleration or that there may be a system tray icon for the graphics settings. This is system wide and not local.
-
3Note this disables ALL hardware graphics acceleration in the system, not just WPF. – itowlson Jan 30 '10 at 22:14
-
This is not available in most systems, as both nVidia and Ati do not allow you to disable (or even alter) the hardware acceleration as long as their drivers are installed. @itowlson has the correct answer to this. – Odys Feb 1 '14 at 16:36
-
Agree with @itowlson. This disables all hardware acceleration when WPF alone can be disabled mentioned below – Jippers Mar 21 '14 at 20:31
You can disable it on a Window
level starting from .Net 3.5 SP1.
public partial class MyWindow : Window
{
public MyWindow()
: base()
{
InitializeComponent();
}
protected override void OnSourceInitialized(EventArgs e)
{
var hwndSource = PresentationSource.FromVisual(this) as HwndSource;
if (hwndSource != null)
hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly;
base.OnSourceInitialized(e);
}
}
or you can subscribe to SourceInitialized
event of the window and do the same.
Alternatively you can set it on Process level:
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
The precedence order for software rendering is:
- DisableHWAcceleration registry key
- ProcessRenderMode
- RenderMode (per-target)
It is a machine-wide registry setting. See Graphics Rendering Registry Settings in the WPF docs for the registry key and other details relating to customizing WPF rendering.
The key listed is:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\DisableHWAcceleration
The MSDN document is "not available" for .NET 4.5, so this may be a depricated option that only works in 4.0 or below.
-
1
-
2It's far better to just disable it for YOUR app. See the other answer by Konstantin – Warren P Jul 7 '15 at 15:47
-
@WarrenP Certainly, but sometimes you're dealing with a broken program or just you don't have access to the code, the registry becomes a last resort. – Alejandro Jan 5 '17 at 18:42
-
Another, I think newer link: docs.microsoft.com/en-us/dotnet/framework/wpf/… – akostadinov Apr 6 '18 at 9:07
In version 4.0, you can also use RenderOptions.ProcessRenderMode
to set a process wide preference (http://msdn.microsoft.com/en-us/library/system.windows.media.renderoptions.processrendermode.aspx).