WPF - GDI/GDI+的末路, Direct3D的盛宴

GDI/GDI+ 是什麼

GDI is the main graphics library for Windows applications today. It provides 2D graphics and text functionality, as well as limited imaging functionality. There is some level of acceleration support in graphics cards for GDI, but it is almost negligible nowadays (especially when compared to the level of investment in Direct3D acceleration).

GDI+ was introduced around 2001 and it brought anti-aliased 2D graphics, floating point coordinates, gradients, per-pixel alpha value support, and support for multiple image formats to the Windows platform, but no hardware acceleration abstraction (all rendering is done in software). Windows Form provides managed wrappers on top of the GDI+ interfaces.

 

GDI/GDI+的前途
 

如果微軟按下面的計劃執行,那麼GDI/GDI+在未來不會有什麼發展,可能會逐漸淡出主流了。


We continue to put a lot of effort in ensuring compatibility for GDI and GDI+ (and Windows as a whole I might add) for every Windows release, and both technologies will continue to be supported, but no functionality improvements are planned in these technologies for future Windows releases. Of course, we will continue to address security and customer issues; if any arise (the GDI and GDI+ development work takes place as part of the Avalon organization – we invest significant time on GDI/GDI+ work).

 

WPF如何實現的

 

WPF GDI/GDI+是不同技術實現。它是對DirectXmanaged封裝,準確的說是Direct3D,所有2D的表現也都是通過其實現。由於Direct3D是基於硬件的Native API,而WPFmanaged code,因此WPF存在managed codenative資源的交互開銷。這一點很象GDI+是對native GDI的封裝,同樣存在類似開銷。因此,對於性能要求甚高的3D遊戲,直接使用DirectX要比WPF 在性能表現上要強。

 

Windows Presentation Foundation does not depend on either GDI or GDI+ for its rendering (GDI, GDI+, and WPF coexist side by side). The mainstream scenario has Windows Presentation Foundation doing all its rendering through Direct3D, for all primitives (2D, text, imaging, video, and of course 3D), through Direct3D’s native interface (the managed/native transition takes place within the Windows Presentation Foundation stack, as the bulk of WPF was written in managed code).

 

 

正由於WPF依賴於Direct3D,因此它的圖形的表現依賴於硬件顯卡。如果,硬件本身不支持一些圖形特效的硬實現,那麼會不會對WPF編程帶來複雜性,代碼中還需要判斷硬件是否適用?

 

不必擔心,既然是對Direct3D的一種更高層次的封裝,開發人員可以不必考慮硬件:硬實現不支持(GPU的工作),那麼會有軟實現(CPU的工作)

 

Windows Presentation Foundation takes advantage of hardware rendering as appropriate. It uses Direct3D to provide accelerated rendering on DirectX 7 or above, with further optimization for graphics cards with DirectX 9 and Pixel Shader 2.0 hardware. For machines without these capabilities, Windows Presentation Foundation uses software rendering, a CPU-based, SSE and SSE2 optimized rasterizer. This is also used when Windows Presentation Foundation is unable to render something using the hardware pipeline, and guarantees that rendering output is available across all machine hardware configurations.

As a result, Windows Presentation Foundation has both hardware and software pipelines, both with difference performance characteristics. This could make application performance very difficult to predict, since there are two code paths. In practice, hardware is reliably faster; for a given application, it's simply a matter of setting a minimum requirement. Windows Presentation Foundation supports simple runtime hardware detection and allows you to dynamically tailor your application for the platform it's running on using resource dictionaries.

 

Will Windows Presentation Foundation require a certain level of video card?

 

Windows Presentation Foundation will take advantage of the latest graphics cards, but it can also use software emulation if a system doesn't have a supported video card.

 

軟實現是需要耗費更多的CPU資源,因此硬件對於WPF在性能方面的表現有很大影響。那麼發揮WPF價值的硬件有什麼要求?

 

      What graphics card should I use for Windows Presentation Foundation?

Any high performance DX9 Pixel Shader 2.0 card will give good results. The fastest PS 2.0 card with the most memory your bank account can afford is the ticket.

 

若干年前上演過 Win+Intel的神話,今天一場WPF+顯卡硬件廠商的盛宴又要開始了。

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章