WPF Rendering 1(硬件加速、软件加速)

 Plan:

Area: Graphics      Title: Rendering

Scenario:

1. Use software rendering
2. Use hardware rendering
3. Iterate

Stress Attack Point:Memory leak – Graphics rendering leaking          Failure:  Out of memory

Estimated Time: 2010/11/15-2010/11/19

First day(2010/11/15)

step 1: Material search

1. About DirectX http://baike.baidu.com/view/15762.htm

2. WPF Graphics Rendering Overview http://msdn.microsoft.com/zh-cn/library/ms748373.aspx

3. Optimizing Performance: Taking Advantage of Hardware http://msdn.microsoft.com/zh-cn/library/bb613578.aspx

4. WPF 性能分析工具 http://msdn.microsoft.com/zh-cn/library/aa969767(VS.90).aspx

5. Graphics Rendering Registry Settings

http://msdn.microsoft.com/zh-cn/library/aa970912.aspx

Main point:

禁用硬件加速选项

注册表项

      值类型

      HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\DisableHWAcceleration

          DWORD

使用禁用硬件加速选项,可以出于调试和测试的目的而关闭硬件加速。在应用程序中看到呈现项目时,尝试关闭硬件加速。如果项目消失,则视频驱动程序可能有问题。

“禁用硬件加速选项”是一个等于 0 或 1 的 DWORD 值。如果值为 1,则禁用硬件加速。假如系统满足硬件加速要求,则值 0 将启用硬件加速;有关更多信息,请参见图形呈现层

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

http://stackoverflow.com/questions/149763/how-do-you-determine-if-wpf-is-using-hardware-or-software-rendering

Main point:

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

7. What’s New for Performance in WPF in .NET 4

http://blogs.msdn.com/b/jgoldb/archive/2010/04/12/what-s-new-for-performance-in-wpf-in-net-4.aspx

Main point: New API to allow WPF apps to force SW rendering per process
In NET 3.5 SP1 we added new API to allow developers to force software rendering per application window instead of using the GPU (see my Performance improvements in WPF in .Net 3.5 / 3.0 SP1 blog), in NET 4 you can now do so for the entire process.

As reported (see here), depending on the machine configuration and the application, software-based rendering is sometimes faster than hardware.
This could improve rendering performance for certain scenarios and machines configuration, in most cases Hardware rendering should perform better. Please use carefully and verify with your app and machine configuration.
In certain cases apps may want to use Software rendering for reliability reasons, for example on machines (typically older) that do not have reliable drivers.
This APIs should provide developers a much better alternative than setting the global ‘Disable HW Acceleration’ registry key (see here)

VS 2010 for example is using this feature to force VS 2010 into Software rendering on VMs thus improving reliability. VS 2010 is doing so since some VMs graphic emulation drivers found VS 2010 is doing so since some VMs graphic emulation drivers found not to be reliable. Here is an example for how to use this API:

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

Notes:
I) The precedence order for software rendering is:

  1. DisableHWAcceleration reg key
  2. RenderOptions.ProcessRenderMode (per process)
  3. HwndTarget.RenderMode (per-target / window)

II) The app force Software rendering at any time, however there is no way to force Hardware rendering back on once it was set to SoftwareOnly.

8. System.Windows.Media.RenderCapability.Tier returns not the render mode

http://stackoverflow.com/questions/3060329/system-windows-media-rendercapability-tier-returns-not-the-render-mode

Main point:

HwndSource hwndSource = PresentationSource.FromVisual(visual) as System.Windows.Interop.HwndSource; 
HwndTarget hwndTarget = hwndSource.CompositionTarget; 
hwndTarget
.RenderMode = renderMode; 
9.
RegistryKey Class

http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.aspx

转载于:https://www.cnblogs.com/mycom/archive/2010/11/15/1877878.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WPF(Windows Presentation Foundation)开发三维设计软件一种利用Microsoft的WPF技术来创建具有三维功能的设计应用程序的方法。WPF是一种用于构建Windows桌面应用程序的UI框架,它提供了强大的图形渲染和用户界面控件。 下面是一些实现基于WPF的三维设计软件的步骤: 1. 项目设置:创建一个WPF项目,并设置合适的项目属性和引用。确保项目包含所需的3D渲染和图形库。 2. 界面设计:设计一个用户友好的界面,包括工具栏、视图窗口、属性面板等元素。用户可以通过界面进行三维模型的创建、编辑和查看。 3. 3D模型创建:使用WPF提供的3D图形库创建三维模型。WPF支持基本的几何体(如立方体、圆柱体、球体)和复杂的网格模型。可以使用编程方式或XAML来定义和构建模型。 4. 模型编辑:实现对三维模型的编辑功能,例如平移、旋转、缩放等操作。通过WPF的输入事件和变换操作,可以实现对模型的交互式编辑。 5. 材质和纹理:为三维模型应用适当的材质和纹理。WPF提供了多种材质类型(如颜色、纹理、渐变等),可以根据需求进行设置。 6. 光照和阴影:添加光源来照亮三维模型,并生成逼真的阴影效果。WPF支持不同类型的光源(如定向光、点光源、聚光灯),可以通过设置光源参数来调整光照效果。 7. 动画和交互:实现模型的动画效果和用户交互。WPF提供了动画和触发器功能,可以创建模型的变换动画或响应用户操作的交互效果。 8. 导出和保存:实现将三维模型导出为文件或保存到数据库的功能。这样用户可以在其他应用程序中使用或分享他们的设计。 需要注意的是,基于WPF开发三维设计软件需要有一定的前端开发知识和对WPF框架的理解。同时,考虑到性能和用户体验,需要进行优化和测试,以确保软件在各种Windows设备上的良好运行。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值