The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,878 other followers

.NET/C# – determining the hardware acceleration support for your WPF apps

Posted by jpluimers on 2010/05/13

When you want to deploy WPF, it is important to check if you have sufficient hardware acceleration for your apps.

The most important things to check is the RenderCapability.
It gives you the  Tier on which graphics is rendered.

The Tier tells something about hardware acceleration support, including a broad estimate of the pixel shader and vertex shader levels and DirectX versions.

Currently, there are 3 tiers:

  • Tier zero:
    • no acceleration at all;
    • often an old DirectX version (< 7) or running over RDP.
  • Tier one:
    • basic hardware acceleration;
    • DirectX versions 7 through 9,
    • more than 30 megs of video RAM,
    • at least PixelShader 1.0 and VertexShader 1.0 support
  • Tier two: DirectX 10 and up,
    • advanced hardware acceleration;
    • more than 120 megs of video RAM,
    • at least PixelShader 2.0 and VertexShader 2.0 support,
    • and at least 4 MultiTexture units

Without proper acceleration, your apps will be slower than you want.
You can partially get around this by optimization, and by lowering your standards (which users often won’t even notice!).
Another thing you can do is partially downgrade the graphical capabilities of your application depending on the rendering tier.

The dynamic aspecf of WPF apps can make it tough to optimize them, which can make a huge difference if your hardware is not up to par.

MSDN has an excellent presentation on WPF Performance & Best Practices linked from a great chapter about Optimizing WPF Application Performance.
There are many more interesting web pages linking to the PPT.
Recommended reading when you want to improve WPF performance in your applications.

Here is the code:

using System;
using System.Windows.Media;

namespace RenderCapabilityConsoleApplication
    class Program
        static void Main(string[] args)
            Console.WriteLine("Tier: {0}", RenderCapability.Tier >> 16);
            short[] pixelShaderVersionsTimesTen =
                    10, // 1.0
                    11, // 1.1
                    12, // 1.2
                    13, // 1.3
                    14, // 1.4
                    20, // 2.0
                    30, // 3.0
                    40, // 4.0
                    41, // 4.1
                    50  // 5.0
            foreach (short pixelShaderVersionTimesTen in pixelShaderVersionsTimesTen)
                short ten = 10;
                short pixelShaderMajorVersion = (short)(pixelShaderVersionTimesTen / ten);
                short pixelShaderMinorVersion = (short)(pixelShaderVersionTimesTen % ten);
                Console.WriteLine("IsPixelShaderVersionSupported({0}, {1}): {2}", pixelShaderMajorVersion, pixelShaderMinorVersion, RenderCapability.IsPixelShaderVersionSupported(pixelShaderMajorVersion, pixelShaderMinorVersion));
#if (SupportWPF4)
                Console.WriteLine("MaxPixelShaderInstructionSlots({0}, {1}): {2}", pixelShaderMajorVersion, pixelShaderMinorVersion, RenderCapability.MaxPixelShaderInstructionSlots(pixelShaderMajorVersion, pixelShaderMinorVersion));
#if (SupportWPF4)
            Console.WriteLine("MaxHardwareTextureSize : {0}", RenderCapability.MaxHardwareTextureSize );
            Console.WriteLine("IsPixelShaderVersionSupportedInSoftware: {0}", RenderCapability.IsPixelShaderVersionSupportedInSoftware);
            Console.WriteLine("IsShaderEffectSoftwareRenderingSupported: {0}", RenderCapability.IsShaderEffectSoftwareRenderingSupported);
            Console.Write("Press <Enter>");


One Response to “.NET/C# – determining the hardware acceleration support for your WPF apps”

  1. […]; […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: