如何确定WPF是使用硬件还是软件渲染?

时间:2021-09-16 07:15:49

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.

我在各种平台上测试WPF应用程序,我需要一种简单的方法来确定WPF是否在使用硬件或软件渲染。

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?

另外,是否有一个简单的、基于代码的方法来强制一个呈现管道在另一个之上?

7 个解决方案

#1


32  

Check the RenderCapability.Tier

检查RenderCapability.Tier

[UPDATE]

(更新)

  • RenderCapability.IsPixelShaderVersionSupported - Gets a value that indicates whether the specified pixel shader version is supported.
  • RenderCapability。获取一个值,该值指示是否支持指定的像素着色器版本。
  • RenderCapability.IsShaderEffectSoftwareRenderingSupported - Gets a value that indicates whether the system can render bitmap effects in software.
  • RenderCapability。isshadereffectsoftwarerenderingsupport -获取一个值,该值指示系统是否可以在软件中呈现位图效果。
  • RenderCapability.Tier - Gets a value that indicates the rendering tier for the current thread.
  • RenderCapability。层——获取一个值,该值指示当前线程的呈现层。
  • RenderCapability.TierChanged - Occurs when the rendering tier has changed for the Dispatcher object of the current thread.
  • RenderCapability。TierChanged—当当前线程的Dispatcher对象的呈现层发生更改时发生。

RenderCapability.Tier >> 16

RenderCapability。层> > 16

  • Rendering Tier 0 - No graphics hardware acceleration. The DirectX version level is less than version 7.0.
  • 渲染层0 -没有图形硬件加速。DirectX版本级别小于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.
  • 渲染层1 -部分图形硬件加速。DirectX版本级别大于或等于version 7.0,小于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.
  • 渲染层2 -大多数图形特性使用图形硬件加速。DirectX版本级别大于或等于9.0版本。

#2


11  

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

net 4.0提供了在代码中强制执行软件的能力:

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

See this post for more information.

更多信息见此帖子。

#3


6  

Maybe the following can help with the second part of your question, that is, can you force one rendering pipeline over another:

也许下面的问题可以帮助你解决问题的第二部分,也就是说,你能不能强迫一个渲染管道超过另一个?

You can change a registry setting to disable hardware acceleration and force software rendering to occur at all times. We often use this to see if a particular issue we are seeing ... is related to video drivers. As an example of what I am talking about see this WPF forum post.

您可以更改注册表设置来禁用硬件加速,并在任何时候强制执行软件呈现。我们经常用这个来看看我们正在看到的某个问题……与视频驱动有关。作为一个例子,我正在谈论的是看到这个WPF论坛帖子。

One obvious thing to note here though ... is that this affects all WPF applications and really should only be used for testing purposes.

这里有一件很明显的事情要注意……这影响到所有WPF应用程序,实际上应该只用于测试目的。

To disable hardware acceleration:

禁用硬件加速:

[HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics]
"DisableHWAcceleration"=dword:00000001

To enable hardware acceleration:

启用硬件加速:

[HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics]
"DisableHWAcceleration"=dword:00000000

Check out this MSDN link for more info.

查看此MSDN链接获得更多信息。

#4


5  

Based on the RenderingTier links, here is some code:

基于RenderingTier链接,这里有一些代码:

        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.

我还在测试和研究这个。查看未来的编辑/答案。

#5


4  

Or use the Profiling Tools...

或者使用分析工具……

New checkbox was added to tint the target application elements that use SW rendered legacy Bitmap Effects.

新的复选框被添加到使用SW渲染的遗留位图效果的目标应用程序元素上。

#6


1  

To answer the second half of your question, there is no way I believe really to force one way over the other. Hardware rendering is automatically used if available, otherwise, software is.

为了回答你问题的后半部分,我认为真的没有办法让一种方法凌驾于另一种方法之上。如果可用,则自动使用硬件呈现,否则使用软件。

If you need to test it in Software mode, you'll need to use a low spec machine or use Remote Desktop to view the application running on another computer. Apart from reduced performance/framerate however, there shouldn't be any visible differences in appearance between the two. Use the RenderCapability class to know if you should disable things such as animation or effects in favour of performance.

如果需要在软件模式下进行测试,则需要使用低规格的机器或使用远程桌面来查看运行在另一台计算机上的应用程序。但是,除了降低性能/帧速率外,这两者之间不应该有任何明显的区别。使用RenderCapability类来了解是否应该禁用诸如动画或效果之类的内容以提高性能。

#7


0  

I agreee with the second answer but that just says something about the ability of the machine to run using hw rendering not if the app is actually hw rendered.

我同意第二个答案,但这只是说明了机器使用hw呈现的能力,而不是如果应用程序是hw呈现的。

I made a simple app using a canvas and just rotating a rectangle with RotateTransform uses way to much CPU for a hw rendered application. That and the 'RenderCapability.Tier' value is 2 so there's enough hw capability to do it.

我用画布制作了一个简单的应用程序,用RotateTransform旋转一个矩形就可以在hw渲染的应用程序中使用大量的CPU。这和“RenderCapability。层的值是2,所以有足够的hw能力。

Why doesn't then?

为什么不呢?

#1


32  

Check the RenderCapability.Tier

检查RenderCapability.Tier

[UPDATE]

(更新)

  • RenderCapability.IsPixelShaderVersionSupported - Gets a value that indicates whether the specified pixel shader version is supported.
  • RenderCapability。获取一个值,该值指示是否支持指定的像素着色器版本。
  • RenderCapability.IsShaderEffectSoftwareRenderingSupported - Gets a value that indicates whether the system can render bitmap effects in software.
  • RenderCapability。isshadereffectsoftwarerenderingsupport -获取一个值,该值指示系统是否可以在软件中呈现位图效果。
  • RenderCapability.Tier - Gets a value that indicates the rendering tier for the current thread.
  • RenderCapability。层——获取一个值,该值指示当前线程的呈现层。
  • RenderCapability.TierChanged - Occurs when the rendering tier has changed for the Dispatcher object of the current thread.
  • RenderCapability。TierChanged—当当前线程的Dispatcher对象的呈现层发生更改时发生。

RenderCapability.Tier >> 16

RenderCapability。层> > 16

  • Rendering Tier 0 - No graphics hardware acceleration. The DirectX version level is less than version 7.0.
  • 渲染层0 -没有图形硬件加速。DirectX版本级别小于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.
  • 渲染层1 -部分图形硬件加速。DirectX版本级别大于或等于version 7.0,小于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.
  • 渲染层2 -大多数图形特性使用图形硬件加速。DirectX版本级别大于或等于9.0版本。

#2


11  

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

net 4.0提供了在代码中强制执行软件的能力:

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

See this post for more information.

更多信息见此帖子。

#3


6  

Maybe the following can help with the second part of your question, that is, can you force one rendering pipeline over another:

也许下面的问题可以帮助你解决问题的第二部分,也就是说,你能不能强迫一个渲染管道超过另一个?

You can change a registry setting to disable hardware acceleration and force software rendering to occur at all times. We often use this to see if a particular issue we are seeing ... is related to video drivers. As an example of what I am talking about see this WPF forum post.

您可以更改注册表设置来禁用硬件加速,并在任何时候强制执行软件呈现。我们经常用这个来看看我们正在看到的某个问题……与视频驱动有关。作为一个例子,我正在谈论的是看到这个WPF论坛帖子。

One obvious thing to note here though ... is that this affects all WPF applications and really should only be used for testing purposes.

这里有一件很明显的事情要注意……这影响到所有WPF应用程序,实际上应该只用于测试目的。

To disable hardware acceleration:

禁用硬件加速:

[HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics]
"DisableHWAcceleration"=dword:00000001

To enable hardware acceleration:

启用硬件加速:

[HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics]
"DisableHWAcceleration"=dword:00000000

Check out this MSDN link for more info.

查看此MSDN链接获得更多信息。

#4


5  

Based on the RenderingTier links, here is some code:

基于RenderingTier链接,这里有一些代码:

        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.

我还在测试和研究这个。查看未来的编辑/答案。

#5


4  

Or use the Profiling Tools...

或者使用分析工具……

New checkbox was added to tint the target application elements that use SW rendered legacy Bitmap Effects.

新的复选框被添加到使用SW渲染的遗留位图效果的目标应用程序元素上。

#6


1  

To answer the second half of your question, there is no way I believe really to force one way over the other. Hardware rendering is automatically used if available, otherwise, software is.

为了回答你问题的后半部分,我认为真的没有办法让一种方法凌驾于另一种方法之上。如果可用,则自动使用硬件呈现,否则使用软件。

If you need to test it in Software mode, you'll need to use a low spec machine or use Remote Desktop to view the application running on another computer. Apart from reduced performance/framerate however, there shouldn't be any visible differences in appearance between the two. Use the RenderCapability class to know if you should disable things such as animation or effects in favour of performance.

如果需要在软件模式下进行测试,则需要使用低规格的机器或使用远程桌面来查看运行在另一台计算机上的应用程序。但是,除了降低性能/帧速率外,这两者之间不应该有任何明显的区别。使用RenderCapability类来了解是否应该禁用诸如动画或效果之类的内容以提高性能。

#7


0  

I agreee with the second answer but that just says something about the ability of the machine to run using hw rendering not if the app is actually hw rendered.

我同意第二个答案,但这只是说明了机器使用hw呈现的能力,而不是如果应用程序是hw呈现的。

I made a simple app using a canvas and just rotating a rectangle with RotateTransform uses way to much CPU for a hw rendered application. That and the 'RenderCapability.Tier' value is 2 so there's enough hw capability to do it.

我用画布制作了一个简单的应用程序,用RotateTransform旋转一个矩形就可以在hw渲染的应用程序中使用大量的CPU。这和“RenderCapability。层的值是2,所以有足够的hw能力。

Why doesn't then?

为什么不呢?