• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            永遠也不完美的程序

            不斷學習,不斷實踐,不斷的重構……

            常用鏈接

            統計

            積分與排名

            好友鏈接

            最新評論

            復習一下D3D渲染流程

                   
            摘自http://www.cnblogs.com/ixnehc/articles/1282350.html
            我歸納一下就是:準備頂點和圖元數據----》傳到D3D渲染管線----》處理頂點數據(固定、shader)----》幾何處理(裁剪、背面剔除、光柵化)----》像素處理(紋理采樣)----》著色
            牢記這個:

            Direct3D Graphics Pipeline

            The graphics pipeline provides the horsepower to efficiently process and render Direct3D scenes to a display, taking advantage of available hardware. This figure conceptually illustrates the building blocks of the pipeline:

            Direct3D graphics pipeline diagram

            Pipeline Component Description Related Topics
            Vertex Data Untransformed model vertices are stored in vertex memory buffers. Vertex Buffers (Direct3D 9), IDirect3DVertexBuffer9
            Primitive Data Geometric primitives, including points, lines, triangles, and polygons, are referenced in the vertex data with index buffers. Index Buffers (Direct3D 9), IDirect3DIndexBuffer9, Primitives, Higher-Order Primitives (Direct3D 9)
            Tessellation The tesselator unit converts higher-order primitives, displacement maps, and mesh patches to vertex locations and stores those locations in vertex buffers. Tessellation (Direct3D 9)
            Vertex Processing Direct3D transformations are applied to vertices stored in the vertex buffer. Vertex Pipeline (Direct3D 9)
            Geometry Processing Clipping, back face culling, attribute evaluation, and rasterization are applied to the transformed vertices. Pixel Pipeline (Direct3D 9)
            Textured Surface Texture coordinates for Direct3D surfaces are supplied to Direct3D through the IDirect3DTexture9 interface. Direct3D Textures (Direct3D 9), IDirect3DTexture9
            Texture Sampler Texture level-of-detail filtering is applied to input texture values. Direct3D Textures (Direct3D 9)
            Pixel Processing Pixel shader operations use geometry data to modify input vertex and texture data, yielding output pixel color values. Pixel Pipeline (Direct3D 9)
            Pixel Rendering Final rendering processes modify pixel color values with alpha, depth, or stencil testing, or by applying alpha blending or fog. All resulting pixel values are presented to the output display. Pixel Pipeline (Direct3D 9)

            Direct3D System Integration

            This figure shows the relationships between a Window application, Direct3D,GDI, and the hardware:

            Direct3D system relationship diagram

            Direct3D exposes a device-independent interface to an application. Direct3D applications can exist alongsideGDI applications, and both have access to the computer's graphics hardware through the device driver for the graphics card. UnlikeGDI, Direct3D can take advantage of hardware features by creating a hal device.

            A hal device provides hardware acceleration to graphics pipeline functions, based upon the feature set supported by the graphics card. Direct3D methods are provided to retrieve device display capabilities at run time. (See IDirect3D9::GetDeviceCaps and IDirect3DDevice9::GetDeviceCaps.) If a capability is not provided by the hardware, the hal does not report it as a hardware capability.

            For more information about hal and reference devices supported by Direct3D, see Device Types (Direct3D 9).

            *.首先Device的使用者要準備好頂點數據,也就是一個頂點的數組,稱為A 
            *.然后這個數組A被傳入device的渲染管線
            *.device內部依次對每個頂點進行處理,有兩種模式,固定管線和shader模式,所謂固定管線就是device內部實現的一個固定的程 序,用戶只能通過設定各種參數(一些RenderState)來控制它,當然這不夠靈活,所以有了shader模式,也就是說,用戶需要寫一個程序片段 (所謂vertex shader),傳給device,然后device使用這個片段對每個頂點進行處理.這個程序片段是在顯卡上執行的.
            *.傳入的頂點數組A的每一個元素被轉換后,存儲到另一個數組B中.數組B中的每個元素必須至少包含一個透視空間的位置,用來做裁剪.
            *.數組B被傳入到device的下一個計算階段,在這個階段里,數組B中的(被轉換過的)頂點被組織成一個個三角形,然后對這些三角形進行裁 剪(利用頂點數據里包含的那一個透視空間的位置),背面剔除(注意背面剔除和頂點的法線是沒關系的),最后剩下的三角形被保存到一個數組C中.(注意在這 個階段里頂點數組變成了三角形數組)
            *.數組C被傳入到下一個計算階段,光柵化,對于數組C中每一個三角形,首先把它們從透視空間映射到屏幕空間,然后找出它們在屏幕上覆蓋的像素 (一個三角形覆蓋的像素的數量有可能是很多的),對于每一個像素,根據它在三角形中的位置,通過三角形的頂點進行線性插值,計算出一個像素數據(注意像素 數據是通過三角形的頂點數據插值而來,所以它們的數據類型是一致的),所有三角形算出來的像素數據最后被存儲到一個數組D中.(在這個階段里,三角形的數 組變成了像素數據數組)
            *.數組D被傳入到下一個計算階段,在這個階段里,device會對這些像素做一些初步的過濾,主要是進行stencil test(根據stencil
            buffer上的值)和z-test(根據這個像素的Z值和z-buffer上的值進行比較),根據測試結果會對stencil buffer進行一些修改(使用一組render state來控制這個過程),通過這些test的像素被存儲到數組E.
            *.數組E被傳入到下一個計算階段,在這個階段里,device對每個像素數據進行處理,這個階段也有兩種模式,固定管線和shader模式, 與頂點處理階段類似,用戶也可以寫一個程序片段,來對每一個像素數據進行處理,稱為pixel shader.像素數據可能包含各種類型的數據,但經過這一階段的處理后,輸出是很簡單的,一般就是一個顏色值和一個alpha值(透明度),也可以輸出 一個Z值,不過好像不常用.在pixel shader里還可以使用專門的指令來放棄某一個像素的后續處理.所有的像素數據被處理后,結果存在一個數組F中.
            *.數組F進入下一個階段,在這一個階段里,進行alpha test(根據像素的alpha 值),alpha test是最后一個test了,通過了alpha test的像素可以保證繪制到屏幕上去,通過test的像素會把它們的z值更新到z-buffer中去(具體由一組render state控制),通過test的像素被存入數組G
            *.數組G進入下一個階段,在這個階段里,主要是把數組G里的像素和屏幕上已有的像素進行混合,具體混合的方式有多種多樣,由一系列render state進行控制.混合以后的像素就被"畫"到屏幕上了

            posted on 2009-05-11 22:21 狂爛球 閱讀(4227) 評論(2)  編輯 收藏 引用 所屬分類: 圖形編程

            評論

            # re: 復雜一下D3D渲染流程 2009-05-11 23:06 chib

            @@ 標題??  回復  更多評論   

            # re: 復習一下D3D渲染流程 2009-05-12 10:25 Sail Tsao

            原來標題是復習.....汗一個....  回復  更多評論   

            麻豆成人久久精品二区三区免费 | 久久精品国产亚洲AV大全| 国产精品久久久久久五月尺| 久久精品国产亚洲AV影院| AV无码久久久久不卡网站下载| 91亚洲国产成人久久精品| 亚洲乱码日产精品a级毛片久久| 亚洲AV日韩AV天堂久久| 久久免费观看视频| 精品久久久久久久无码| 久久亚洲精品视频| 精品久久人人妻人人做精品 | 色综合久久无码中文字幕| 91精品国产色综久久| 久久午夜福利无码1000合集| 久久国产色AV免费看| 日本久久中文字幕| 国产精品欧美久久久久无广告 | 久久久久亚洲国产| 狠狠色丁香婷婷综合久久来来去 | 97久久精品无码一区二区天美| 欧美亚洲国产精品久久| 亚洲伊人久久大香线蕉苏妲己| 一本久道久久综合狠狠躁AV| 久久精品国产半推半就| 成人久久精品一区二区三区 | 色综合久久综精品| 久久久久成人精品无码中文字幕| 久久久久久亚洲精品无码| 久久久久97国产精华液好用吗| 国产成人精品久久免费动漫| 亚洲va中文字幕无码久久不卡| 亚洲精品无码久久毛片| 香蕉久久AⅤ一区二区三区| 国产精品久久久久一区二区三区| 久久香蕉国产线看观看乱码| 久久精品国产亚洲AV麻豆网站| 久久精品国产2020| 亚洲香蕉网久久综合影视 | 久久精品国产免费| 久久香蕉一级毛片|