📄 可编程流水线 (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
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>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>
<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">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 + -