Quick Start for Direct3D 9 for Developer

   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.

 

 

 

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