[ACCEPTED]-How do you determine if WPF is using Hardware or Software Rendering?-pipeline
Check RenderCapability.Tier
[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.
0
.NET 4.0 provides the ability to force software 1 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.
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 2 testing and working on this. See future 1 edits/answers for what I find.
Maybe the following can help with the second 14 part of your question, that is, can you 13 force one rendering pipeline over another:
You 12 can change a registry setting to disable 11 hardware acceleration and force software 10 rendering to occur at all times. We often 9 use this to see if a particular issue we 8 are seeing ... is related to video drivers. As 7 an example of what I am talking about see 6 this WPF forum post.
One obvious thing to note here though 5 ... is that this affects all WPF applications 4 and really should only be used for testing 3 purposes.
To disable hardware acceleration:
[HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics]
"DisableHWAcceleration"=dword:00000001
To 2 enable hardware acceleration:
[HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics]
"DisableHWAcceleration"=dword:00000000
Check out this 1 MSDN link for more info.
Or use the Profiling Tools...
New checkbox was added to 2 tint the target application elements that 1 use SW rendered legacy Bitmap Effects.
I agreee with the second answer but that 9 just says something about the ability of 8 the machine to run using hw rendering not 7 if the app is actually hw rendered.
I made 6 a simple app using a canvas and just rotating 5 a rectangle with RotateTransform uses way 4 to much CPU for a hw rendered application. That 3 and the 'RenderCapability.Tier' value is 2 2 so there's enough hw capability to do 1 it.
Why doesn't then?
To answer the second half of your question, there 13 is no way I believe really to force one 12 way over the other. Hardware rendering is 11 automatically used if available, otherwise, software 10 is.
If you need to test it in Software mode, you'll 9 need to use a low spec machine or use Remote 8 Desktop to view the application running 7 on another computer. Apart from reduced 6 performance/framerate however, there shouldn't 5 be any visible differences in appearance 4 between the two. Use the RenderCapability 3 class to know if you should disable things 2 such as animation or effects in favour of 1 performance.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.