如何确定 WPF 使用的是硬件渲染还是软件渲染?
我正在各种平台上对 WPF 应用程序进行基准测试,并且需要一种简单的方法来确定 WPF 是否使用硬件或软件渲染。
我似乎记得曾打电话来确定此事,但现在无法联系。
另外,是否有一种简单的、基于代码的方法来强制一个渲染管道优于另一个渲染管道?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
.NET 4.0 提供了在代码中强制进行软件渲染的功能:
请参阅 这篇文章了解更多信息。
.NET 4.0 provides the ability to force software rendering in code:
See this post for more information.
也许以下内容可以帮助解决您问题的第二部分,即您是否可以强制一个渲染管道优于另一个渲染管道:
您可以更改注册表设置以禁用硬件加速并强制软件渲染始终发生。 我们经常使用它来查看我们看到的特定问题是否与视频驱动程序有关。 作为我正在谈论的示例,请参阅此 WPF 论坛帖子。
不过,这里需要注意的一件明显的事情是,这会影响所有 WPF 应用程序,并且实际上应该仅用于测试目的。
要禁用硬件加速:
要启用硬件加速:
请查看此 MSDN 链接了解更多信息。
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.
One obvious thing to note here though ... is that this affects all WPF applications and really should only be used for testing purposes.
To disable hardware acceleration:
To enable hardware acceleration:
Check out this MSDN link for more info.
基于 RenderingTier 链接< /a>,这是一些代码:
我仍在测试和处理此问题。 请参阅未来的编辑/答案以了解我发现的内容。
Based on the RenderingTier links, here is some code:
I'm still testing and working on this. See future edits/answers for what I find.
或者使用分析工具...
Or use the Profiling Tools...
我同意第二个答案,但这只是说明了机器使用硬件渲染运行的能力,而不是应用程序实际上是硬件渲染的。
我使用画布制作了一个简单的应用程序,仅使用 RotateTransform 旋转一个矩形就占用了硬件渲染应用程序的大量 CPU。 而且“RenderCapability.Tier”值为 2,因此有足够的硬件能力来完成此操作。
那为什么不呢?
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.
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.
Why doesn't then?
为了回答你问题的后半部分,我认为没有办法真正强迫一种方式优于另一种方式。 如果可用,将自动使用硬件渲染,否则,将使用软件渲染。
如果您需要在软件模式下测试它,则需要使用低规格计算机或使用远程桌面查看另一台计算机上运行的应用程序。 然而,除了性能/帧速率降低之外,两者之间在外观上不应该有任何明显的差异。 使用 RenderCapability 类了解是否应该禁用动画或效果等功能以提高性能。
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.Tier
[更新]
RenderCapability.Tier>> 16
Check RenderCapability.Tier
[UPDATE]
RenderCapability.Tier >> 16