?? 可編程流水線 (programmable pipeline).htm
字號:
</SPAN></DIV>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-outline-level: 1"><A
name=把頂點著色器集成到幾何流水線中><B><SPAN
style="FONT-SIZE: 24pt; FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-font-kerning: 18.0pt; mso-fareast-language: ZH-CN">把頂點著色器集成到幾何流水線中<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN></B></A></P><SPAN
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">可編程頂點著色器在操作狀態時會取代<SPAN
lang=EN-US>Microsoft®
Direct3D®的幾何流水線中的變換和光照模塊。實際上,有關變換和光照的狀態都被忽略。但是,如果禁用頂點著色器并重新使用固定功能處理,那么所有當前狀態設置會起作用。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">任何對<SPAN
lang=EN-US>high-order圖元的tessellation操作必須在頂點著色器執行之前完成。對那些在著色器處理后執行表面tessellation的硬件實現來說,必須采用某種方式使之對應用程序不可見。因為在著色器之前一般來說沒有提供語義信息,所以系統使用了一個特殊的token來確定輸入流中的哪個成員表示基位置,所有其它成員都相對于該成員進行插值。Direct3D不支持無法插值的數據通道。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">在輸出時,頂點著色器必須產生齊次裁剪空間中的頂點位置。其它可以產生的數據包括紋理坐標,顏色,霧因子等等。<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">標準圖形流水線會處理著色器輸出的頂點,包括以下操作。<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<UL type=disc>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l0 level1 lfo5"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">圖元組裝<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l0 level1 lfo5"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">根據視棱錐和用戶裁剪平面進行裁剪<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l0 level1 lfo5"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">齊次除法<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l0 level1 lfo5"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">視區縮放<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l0 level1 lfo5"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">背向面和視區剔除<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l0 level1 lfo5"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">設置三角形<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l0 level1 lfo5"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">光柵化<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN> </LI></UL>
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN lang=EN-US
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">Microsoft
DirectX® 9.0的頂點著色器和固定功能流水線的裁剪空間是相同的。更多細節,請參閱<U>裁剪體</U>。<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">可編程幾何流水線是<SPAN
lang=EN-US>Direct3D應用程序編程接口(API)中的一種模式。當啟用時,它會取代頂點流水線。當禁用時,API就切換回固定功能頂點處理。頂點著色器的執行不會影響Direct3D的內部狀態,同樣著色器也不能使用Direct3D的任何狀態。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">應該用<U><SPAN
lang=EN-US>IDirect3DDevice9::CreateVertexShader</SPAN></U>創建一個頂點著色器,并在進行繪制之前調用<U><SPAN
lang=EN-US>IDirect3DDevice9::SetVertexShader</SPAN></U>設置可編程著色器。<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-outline-level: 1"><A
name=把像素著色器集成到圖形流水線中><B><SPAN
style="FONT-SIZE: 24pt; FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-font-kerning: 18.0pt; mso-fareast-language: ZH-CN">把像素著色器集成到圖形流水線中<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN></B></A></P><SPAN
style="mso-bookmark: 把像素著色器集成到圖形流水線中"></SPAN>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">像素處理由像素著色器對每個像素單獨執行。像素著色器可以單獨工作,也可以和頂點著色器及數據流協同工作。開發人員不能憑空對像素著色器進行編程,它們要依賴于上游的數據成員。<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">下面是像素流水線中的操作順序:<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<UL type=disc>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l3 level1 lfo6"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">設置三角形<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l3 level1 lfo6"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">像素著色器(取代固定格式的多重紋理)<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<UL type=circle>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 72.0pt; mso-list: l3 level2 lfo6"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">對顏色、紋理坐標等等進行迭代,<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 72.0pt; mso-list: l3 level2 lfo6"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">對紋理進行取樣<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 72.0pt; mso-list: l3 level2 lfo6"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">對紋理<SPAN
lang=EN-US>/顏色進行混合<o:p></o:p></SPAN></SPAN> </LI></UL>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l3 level1 lfo6"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">霧混合<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l3 level1 lfo6"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">阿爾法、模板、深度測試<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l3 level1 lfo6"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">幀緩存混合<SPAN
lang=EN-US><o:p></o:p></SPAN></SPAN> </LI></UL>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">像素著色器的輸入來自頂點著色器的輸出。寄存器<SPAN
lang=EN-US>v0和v1包含了頂點顏色,它們來自頂點著色器的輸出寄存器oD0和oD1。顏色層中的紋理由諸如tex
t0之類的像素著色器指令引用,系統會根據頂點著色器的輸出寄存器中對應的紋理坐標(如oT0)對紋理進行取樣。像素著色器使用顏色和阿爾法混合指令以及紋理尋址指令對這些輸入進行操控并計算出結果。像素著色器計算得到的結果是寄存器r0的內容或輸出的像素顏色。著色器完成處理后會把處理結果送到霧處理階段和渲染目標混合器做進一步的處理。頂點著色器的輸出提供了像素著色器的輸入。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN lang=EN-US
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">ps_3_0著色器模型和ps_1_X/ps_2_0有些不同的概念。<o:p></o:p></SPAN></P>
<UL type=disc>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l5 level1 lfo7"><SPAN
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">在<SPAN
lang=EN-US>3_0版像素著色器中,最終的霧混合應該由像素著色器執行。因此,像素流水線中的霧混合階段被禁用,像素著色器的輸出被送到像素流水線中的阿爾法/模板/深度測試階段。<o:p></o:p></SPAN></SPAN>
<LI class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l5 level1 lfo7"><SPAN
lang=EN-US
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">3_0版本的頂點著色器不再支持顏色(oDn)和紋理(oTn)寄存器。現在使用的是輸出(on)寄存器,它們的含義由頂點著色器中的聲明指令定義。更多有關vs_3_0中的寄存器和聲明的信息,請參閱<U>Registers
– vs_3_0</U>和<U>dcl_usage</U>。<o:p></o:p></SPAN> </LI></UL>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US
style="FONT-FAMILY: 宋體; mso-bidi-font-family: 宋體; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV></DIV></BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -