Direct3D Device

来源:互联网 发布:windows 微软雅黑字体 编辑:程序博客网 时间:2024/05/28 11:49

Direct3D Device

HAL Device

The primary device type is the hal device, which supportshardware accelerated rasterization and both hardware and software vertexprocessing. If the computer on which your application is running is equippedwith a display adapter that supports Direct3D, your application should use itfor Direct3D operations. Direct3D hal devices implement all or part of thetransformation, lighting, and rasterizing modules in hardware.

基础设备类型是HAL设备,它支持硬件加速光栅 和 硬件软件的顶点处理。如果你运行程序的电脑显卡支持Direct3D,那么你的程序应该用HAL的Direct3D操作。Direct3D HAL在硬件上完成了变换,光照,光栅化的全部或者部分功能。

Applications do not access graphics adapters directly. Theycall Direct3D functions and methods. Direct3D accesses the hardware through thehal. If the computer that your application is running on supports the hal, itwill gain the best performance by using a hal device.

应用程序不直接访问显卡。他们调用Direct3D的函数。Direct3D通过HAL来访问硬件。如果电脑支持HAL,那么用HAL就会获得最佳的性能。

 

Reference Device

Direct3D supports an additional device type called areference device or reference rasterizer. Unlike a software device, thereference rasterizer supports every Direct3D feature. This device is intendedto be used for debugging purposes and is therefore only available on machineswhere the DirectX SDK has been installed. Because these features areimplemented for accuracy rather than speed and are implemented in software, theresults are not very fast. The reference rasterizer does make use of specialCPU instructions whenever it can, but it is not intended for retailapplications. Use the reference rasterizer only for feature testing ordemonstration purposes. To create a reference device, callCreateDevicemethod using D3DDEVTYPE_REF as the device type.

Direct3D支持额外的设备类型-参考设备叫做参考光栅。与软件设备不同,参考光栅只是Direct3D的每一项特征。参考光栅被用来做调试的目的,因此只能在安装了DirectXSDK的电脑才可以使用。这些特征是用软件来实现,他们被用来追求精度而不是速度,但是并不用做具体的应用程序。用参考光栅仅仅用作特征测试或者证明程序的目标。

HAL vs. REF Devices

HAL (Hardware Abstraction Layer) devices and REF (REFerencerasterizer) devices are the two main types of Direct3D device; the first isbased around the hardware support, and is very fast but might not supporteverything; while the second uses no hardware acceleration, so is very slow,but is guaranteed to support the entire set of Direct3D features, in thecorrect way. In general you'll only ever need to use HAL devices, but if you'reusing some advanced feature that your graphics card does not support then youmight need to fall back to REF.

HAL设置和REF设备时Direct3D 设备的两种类型;HAL基于硬件支持,速度非常快但是不一定支持Direct3D的每一项功能;但是REF设置不用硬件加速,因此非常慢,但是它支持Direct3D的所有特征,如果你想用一些你电脑显卡不支持的功能,那么你就得回归至REF了。

The other time you might want to use REF is if the HALdevice is producing strange results - that is, you're sure your code iscorrect, but the result is not what you're expecting. The REF device isguaranteed to behave correctly, so you may wish to test your application on theREF device and see if the strange behavior continues. If it doesn't, it meansthat either (a) your application is assuming that the graphics card supportssomething that it doesn't, or (b) it's a driver bug. If it still doesn't workwith the REF device, then it's an application bug.

另外一种情况你必须用REF就是你用HAL时候出现了一些诡异的结果—也就是说你确信你的代码是正确的,但是结果却不是预期的,。REF能够保证运行正确,因此你想测试你的程序在REF设备上时那些诡异的结果是否依然存在。如果诡异结果结束了,那说明两种情况a:你的显卡声明了一项它并不支持的功能;b:驱动程序有bug。如果诡异依旧存在,那说明你的应用程序有bug。

Hardware vs.Software Vertex Processing

Hardware versus Software vertex processing only really applies to HALdevices. When you push vertices through the pipeline, they need to betransformed (by the world, view, and projection matrices in turn) and lit (by D3D'sbuilt-in lights) - this processing stage is known as T&L (forTransformation & Lighting). Hardware vertex processing means this is donein hardware, if the hardware supports it; ergo, Software vertex processing isdone is software. The general practice is to try creating a Hardware T&Ldevice first, and if that fails try Mixed, and if that fails try Software. (Ifsoftware fails, give up and exit with an error).

硬件和软件顶点处理仅仅使用于HAL设备,当你把顶点送到管道时候,他们需要被转换(世界坐标转换,取景转换,投影转换)和光照(Direct3D的光照)。硬件顶点处理意味着T&L是通过硬件计算。软件顶点处理意味着通过软件计算,通常的先尝试创建硬件T&L,如果失败了就尝试软硬结合,如果再失败了就用软件。(如果软件也失败了,那么就会放弃并退出一个错误。)

Creating a Device (Direct3D 9)

To create a Direct3D device, first create a Direct3D object(see Direct3DCreate9). All rendering devices created by a Direct3D object sharethe same physical resources. If you create multiple rendering devices from asingle Direct3D object, extreme performance penalties will be incurred becausethey share the same hardware.

创建一个Direct3D设备,首先要创建一个Direct3D对象。所有的渲染设备通过一个Direct3D对象创建,他们共享同样的物理资源。如果你从一个Direct3D创建多个渲染设备,极有可能会出现性能下降,因为所有的设备公用同一个硬件。

0 0
原创粉丝点击