织梦CMS - 轻松建站从此开始!

罗索

Quick Start for Direct3D 9 for Developer

jackyhwei 发布于 2011-05-01 13:15 点击:次 
最终,微软公司为他最新3D API保留了名字,只是版本号换了一下。它依然保留它大部分原有的基本概念,如基于COM的接口和对象。它主要的状态机仍然是能使用着色器在屏幕上画东西的设备。
TAG:

Finally Microsoft's new 3D API keeps its old name and only gets a new version number. It even keeps most of its most fundamental concepts like using COM based interfaces and objects. The main state machine is still called the device that uses shader to draw something on the screen. But the step from the former version is wider this time. If we could move from Direct3D 8 to 9 in only a few days Direct3D 10 will properly force us to rethink the architecture of our Direct3D applications.

 最终,微软公司为他最新3D API保留了名字,只是版本号换了一下。它依然保留它大部分原有的基本概念,如基于COM的接口和对象。它主要的状态机仍然是能使用着色器在屏幕上画东西的设备。相比以前的版本,这次的步伐更大.如果说从Direct3D 8到Direct3D 9 只需要几天,Direct3D 10 将需要我们重新思考我们Direct3D应用程序的架构。

What's Lost

One reason for this is the lost backward compatibility for older hardware. Direct3D 10 will only work with GPUS that are fully Direct3D 10 compatible. If you need to support pre Direct3D 10 hardware and want to support the new Direct3D 10 features with the same application you have to write your render code twice for Direct3D 9 and 10.

 这一节很重要的原因是Direct3D 10 抛弃了对老硬件的向后的兼容性。Direct3D只能运行在完全与Direct3D 10兼容的图形处理器上。如果你想要既能支持老的硬件也要支持新的Direct3D 10的特性,你必须分别为Direct3D 9和Direct10的渲染代码。

But this somewhat painful cut has allowed removing some other outdated parts of Direct3D together with the capabilities bits and values. To support older hardware Direct3D 9 has still support fixed function vertex and pixel processing beside the more flexible shader system. With Direct3D 10 these functionality is gone. But not only were the fixed functions axed although every Direct3D 9 shader model is removed. Direct3D 10 will only support the new shader model 4. Together with this the only way to write such a shader is the use of High Level Shader Language (HLSL). Shader assembler is not longer an option and only supported as dissembler output for debugging purposes.

  一些Direct3D过期的特性随位值对一起被移除了。为了支持更老的硬件,Direct3D 9除了支持灵活的shader系统外,还支持固定流水线的定点和像素处理。 随着Direct3D 10的到来,这些功能全部被移除了。不仅固定功能被移除了,Direct3D 9的shader模型也被移除了。Direct3D 10将只支持新版本shader 模型4。写shader的唯一语言将只有HLSL。shader汇编语言将不再支持。

In the resource system we lost the surface type. Depending on the formerly usage it is replaced by different mechanisms. The explicit texture cube object is although gone. In Direct3D 10 cubes have become a special case of a 2D texture.

As any other resource type it can only be created using one of the predefined formats. In Direct3D 10 mode GPUs will no longer be able to offer additional formats with FourCC codes.

  在资源系统里面,我们将不能再使用surface类型。它将被不同的机制所取代。 典型的纹理立方体对象也不再被使用了。在Direct3D 10,立方体已经成为2D纹理的一个特例。任何资源类型只能使用一种预定义的格式来创建。 在Direct3D 10模式下,GPU将不再能够提供fourCC代码的额外格式。

Together with the cut of the fixed function vertex and pixel processing Direct3D 10 lost some other related functions that now need to be done in the shader. On the vertex side there are no more clip planes. The pixel shader is now responsible to make the alpha test and texture coordinate wraps by its own. The whole pipeline functions to generate point sprites are gone. You will need the new geometry shader to replace this.

The basic support for higher order surfaces and tessellation that was part of Direct3D 9 but not supported by the relevant hardware is removed, too.

 随着顶点和像素固定功能的移除,Direct3D 10也抛弃一些需要在shader中操作的功能。 在顶点部分,不再有剪裁面。 像素部分现在只负责做alpha测试和文件坐标的wrap。产生点精灵的整个流水线功能也没有了。你将需要使用几何shader来取代它。作为Direct3D 9 的一部分,hige order面的基本支持和拣选如果不被相关硬件所支持,现在也会被移除。

What's Different

Beside of elements that are lost forever Direct3D 10 changed multiple Direct3D 9 concepts. Direct3D 9 uses the surface type to represent every kind of two dimensional pixel arrays. As example this could be a depth stencil buffer or a single mip map from a texture. Explicit created surfaces like render targets are replaced by 2D textures. The different mip maps of a texture are now called sub resources. But there is no sub resource interface available. Therefore Direct3D 10 uses a new concept to attach these sub resources to the 3D pipeline. View objects defines how the pipeline should look at the data inside a resource object. Beside of limiting such a view to single sub resources they although offer some form of data format conversions.

除了移除了一些元素以后,Direct3D 10也改变了多个Direct3D 9的概念。Direct3D使用surface类型来表示两维的像素数组。比如,深度stencil缓冲区或者是纹理的mipmap。就像是render target显示创建的surface也会被2D纹理所取代。如今,纹理不同的mip map被称为子资源。但是没有子资源接口使用。因此,Direct3D 10使用了一个新的概念将子资源附着到流水线。可视对象就是流水线渲染资源对象的数据而形成的。除了将一个可视对象对应一个资源对象外,它也提供不同形式的数据格式转换。

The cut of the fixed functions vertex and pixel processing reduced the number of necessary render states significant. But as the other non shader units learn some new features the number is still high. To make the render state system faster Direct3D 10 uses collections of render states called state objects. Each one of these collections contains a whole configuration for one part of the 3D Pipeline. Like other resource the need to create once before the first usage. After this is done the configuration stored in this objects is immutable. This made it easier to change multiple states with only one call but requires the application to manage single state changes by itself.

移除了固定流水线,渲染状态大大减少了。但是渲染状态还是不少。为了提供渲染状态系统的效率,Direct3D 10把渲染状态集合称为状态对象。每个状态对象对于3D流水线的每个部分都有一个完整的配置。跟其他资源对象一样,他们在第一次使用的时候需要创建。一旦创建,存储在对象里面的配置信息是不变的。这样一个调用就能更加容易改变多个状态,但是需要应用程序自身管理自己的状态。

The configuration of the texture sampler is done with a state object too. You can assign up to 16 sampler state objects to each shader. The binding to a resource, like a texture, is postponed to the shader program. This allows using the same texture sampler for different textures.

纹理采样器的配置也是通过状态对象配置的。你能够最多分配16个采样器给每一个shader。具体绑定一个纹理资源,将可以延迟到shader程序。这允许为不同的纹理对象使用同样的纹理采样器。

The shader constants that were stored in one arrays per shader type got a new home with Direct3D 10. These values are now stored in a buffer resources that could be attached to special slots. A buffer that is used for these purposes is called a constant buffer. Each shader can access up to 16 of these buffers in one shader program.

shader常量过去是以一个数组保存的,现在它们有新的地方存储他们了。现在这些常量保存在buffer资源里面,并且可能附加在特别的插槽上。这样的buffer通常称为常量buffer。每个shader能访问最多16个常量buffer。

Another significant change is the replacement of the vertex declaration with an input layout. As the vertex declaration described only a binding between the vertex streams and the semantic usage of the fetched elements a input layout goes a step future. It will bind direct to the input register of the vertex shader. This made it necessary to create one input layout for every vertex shader with a different input side. Beside of this change the input layout will although take control over the instancing functionality.

另外一个具体的改变就是使用输入layout来听换顶点声明。顶点声明只是描述了顶点输入流与元素的语法规则的绑定,但是顶点布局向前迈进一大步。它直接绑定到顶点shader的输入寄存器上。这样就必须要使用不同的输入创建输入布局。除了这个变化,顶点布局将能完全控制实例化功能。

Direct3D 10 uses a new extension mechanism called layer. These layers provide functions like additional debug checks or controlling the multithread behavior. The selection of these layers is done during device creation. In comparison to Direct3D 9 the multithread layer is enabled by default.

Direct3D 使用了一个新的叫做layer的扩展机制。这些layer提供的功能就像调试检查或者控制多个读的行为。 这些层在设备创建工程中选择的。与Direct3D 9相比,多个读的层默认是打开的。

Lock and unlock operations are replaced with map and unmap. As the number of resources that could not be directly accessed has increased with Direct3D 10 there is a new function that allows transferring the content of a memory block to a resource without creating a system memory resource.

The draw methods are changed, too. In any place were Direct3D 9 wants the number of primitives you now have to provide the number of vertices. Additional the primitive type is removed from the parameter list and need to be set with another method before you call any draw method. Finally Direct3D 10 lost the methods that allow you to draw directly from a memory block without using buffer resources. One last change concerns the geometry instancing. If you want to use this technique you have to use one of two new special draw methods.

The pixel position is not longer based on the center of a pixel. Therefore there is no more need to add a half pixel offset in both directions for accurate pixel to screen mapping.

The usage of sRGB is not longer based on render states. It is bound to the data format and Direct3D 10 requires a stricter implementation when the hardware read or writes to such a resource.

(weili_2007)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201105/11355.html]
本文出处:CSDN博客 作者:weili_2007
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容