Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you determine if WPF is using Hardware or Software Rendering?

I'm benchmarking a WPF application on various platforms and I need an easy way to determine if WPF is using hardware or software rendering.

I seem to recall a call to determine this, but can't lay my hands on it right now.

Also, is there an easy, code based way to force one rendering pipeline over the other?

like image 945
Charley Rathkopf Avatar asked Sep 29 '08 17:09

Charley Rathkopf


People also ask

Is WPF hardware acceleration?

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.

What does WPF use to render?

WPF uses vector graphics as its rendering data format. Vector graphics—which include Scalable Vector Graphics (SVG), Windows metafiles (. wmf), and TrueType fonts—store rendering data and transmit it as a list of instructions that describe how to recreate an image using graphics primitives.


3 Answers

Check RenderCapability.Tier

  • Graphics Rendering Tiers
  • RenderCapability Class

[UPDATE]

  • RenderCapability.IsPixelShaderVersionSupported - Gets a value that indicates whether the specified pixel shader version is supported.
  • RenderCapability.IsShaderEffectSoftwareRenderingSupported - Gets a value that indicates whether the system can render bitmap effects in software.
  • RenderCapability.Tier - Gets a value that indicates the rendering tier for the current thread.
  • RenderCapability.TierChanged - Occurs when the rendering tier has changed for the Dispatcher object of the current thread.

RenderCapability.Tier >> 16

  • Rendering Tier 0 - No graphics hardware acceleration. The DirectX version level is less than version 7.0.
  • Rendering Tier 1 - Partial graphics hardware acceleration. The DirectX version level is greater than or equal to version 7.0, and lesser than version 9.0.
  • Rendering Tier 2 - Most graphics features use graphics hardware acceleration. The DirectX version level is greater than or equal to version 9.0.
like image 149
rudigrobler Avatar answered Nov 11 '22 15:11

rudigrobler


.NET 4.0 provides the ability to force software rendering in code:

public partial class App : Application 
{    
    protected override void OnStartup(StartupEventArgs e)    
    {         
        if (WeThinkWeShouldRenderInSoftware())            
            RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;    
    }
}

See this post for more information.

like image 43
user259509 Avatar answered Nov 11 '22 14:11

user259509


Based on the RenderingTier links, here is some code:

        logger.InfoFormat("WPF Tier = {0}",RenderCapability.Tier / 0x10000);
        RenderCapability.TierChanged +=
            (sender, args) => logger.InfoFormat("WPF Tier Changed to {0}",
                                                RenderCapability.Tier / 0x10000);

I'm still testing and working on this. See future edits/answers for what I find.

like image 33
Charley Rathkopf Avatar answered Nov 11 '22 14:11

Charley Rathkopf