18

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?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Stefan
  • 529
  • 2
  • 8
  • 15
  • Does this answer your question? [Software rendering mode - WPF](https://stackoverflow.com/questions/4951058/software-rendering-mode-wpf) – Wai Ha Lee Oct 21 '20 at 10:53

5 Answers5

47

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:

  1. DisableHWAcceleration registry key
  2. ProcessRenderMode
  3. RenderMode (per-target)
Konstantin Spirin
  • 20,609
  • 15
  • 72
  • 90
25

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.

JPhi1618
  • 783
  • 1
  • 11
  • 21
itowlson
  • 73,686
  • 17
  • 161
  • 157
  • 1
    _[Your answer is in another castle: when is an answer not an answer?](http://meta.stackexchange.com/questions/225370/your-answer-is-in-another-castle-when-is-an-answer-not-an-answer)_ –  Mar 03 '15 at 01:15
  • 2
    It's far better to just disable it for YOUR app. See the other answer by Konstantin – Warren P Jul 07 '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 05 '17 at 18:42
  • Another, I think newer link: https://learn.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/graphics-rendering-registry-settings – akostadinov Apr 06 '18 at 09:07
16

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).

floele
  • 3,668
  • 4
  • 35
  • 51
2

You can also disble hardware acceleration in WPF App by adding in MainWindow the following code.

protected override void OnSourceInitialized(EventArgs e)
{
    var hwndSource = PresentationSource.FromVisual(this) as HwndSource;

    if (hwndSource != null)
        hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly;

    base.OnSourceInitialized(e);
}

This solved my issue with TeamViewer.

Source: How does one disable hardware acceleration in wpf?

ouflak
  • 2,458
  • 10
  • 44
  • 49
SiRaDuDe
  • 21
  • 2
-9

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.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
t0mm13b
  • 34,087
  • 8
  • 78
  • 110
  • 4
    Note 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 01 '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