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?
A rendering tier value of 1 or 2 means that most of the graphics features of WPF will use hardware acceleration if the necessary system resources are available and have not been exhausted. This corresponds to a DirectX version that is greater than or equal to 9.0.
In the Settings menu, expand the “Advanced” drop-down section found in the left sidebar and then select “System.” Find the “Use hardware acceleration when available” setting. Toggle the switch to the “Off” position and then click “Relaunch” to apply the changes. Warning: Make sure you save anything you're working on.
Unless you're facing an issue that you know is because of hardware acceleration, you shouldn't turn off hardware acceleration. It'll generally do more good than harm, but when you see it is causing you more harm instead, that's when you should turn it off for that one specific app.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With