Asm 着色器参考

着色器驱动可编程图形管道。

顶点着色器参考

顶点着色器差异 汇总了顶点着色器版本之间的差异。

像素着色器参考

像素着色器差异 汇总了像素着色器版本之间的差异。

着色器模型 4 和 5 参考

着色器模型 4 程序集着色器模型 5 程序集部分介绍了着色器模型 4 和 5 支持的说明。

程序集着色器中常量寄存器的行为

可通过两种方法在程序集着色器中设置常量寄存器:

  • 使用 def* 指令之一在程序集代码中声明着色器常量。
  • 使用 Set***ShaderConstant* API 方法之一。

Direct3D 9 着色器常量

在 Direct3D 9 中,给定着色器中定义的常量的生存期仅限于该着色器 (的执行,并且不可重写) 。 Direct3D 9 中定义的常量在着色器之外没有副作用。

下面是使用 Direct3D 9 的示例:

Given: 
    Create shader1 which references c4 and defines it with the def instruction

Scenario 1:
    Call Set***Shader shader1
    Call Set***ShaderConstant* to set c4
    Call Draw
    Result: The shader will see the def'd value in c4

    
Given: 
    Scenario 1 has just completed
    Create shader2 (which references c4 but does not use the def instruction
      to define it) 

Scenario 2: 
    Call Set***Shader shader2
    Call Draw
    Result: The shader will see the value last set in c4 by 
     Set***ShaderConstant* in scenario 1. This is because shader 2 
     didn't def c4.

在 Direct3D 9 中,调用 Get***ShaderConstant* 将仅检索通过 Set***ShaderConstant* 设置的常量值。

Direct3D 8 着色器常量

此行为在 Direct3D 8.x 中有所不同。

Given:
    Create shader1 which references c4 and defines it with the def instruction

Scenario 1 (repeated with Direct3D 8):
    Call Set***Shader with shader1
    Call Set***ShaderConstant to set c4
    Call Draw
    Result: The shader will see the value in c4 from Set***ShaderConstant

在 Direct3D 8.x 中,Set***ShaderConstant 将立即生效。 请考虑以下方案:

Given:
    Create shader1 which references c4 and defines it with the def instruction
    
Scenario 3:
    Call Set***Shader with shader1
    Call Draw
    Result: The shader will see the def'd value in c4

Given:
    Scenario 3 has just completed
    Create shader2 (which references c4 but does not use the def instruction 
      to define it)     
    
Scenario 4 :    
    Call Set***Shader with shader2
    Call Draw
    Result: The shader will see the def'd value in c4 (set by def in shader 1)

不需要的结果是,着色器的设置顺序可能会影响单个着色器观察到的行为。

着色器驱动程序模型要求

Direct3D 9 接口仅限于 DirectX 7 级及更高级别的设备驱动程序接口 (DDI) 驱动程序。 若要检查 DDI 级别,请运行 DirectX 诊断工具并检查保存的文本文件。

仅供参考,Direct3D 8 接口仅适用于 DirectX 6 级及更高级别的 DDI 驱动程序。

着色器二进制格式

着色器指令流的按位布局在 D3d9types.h 中定义。 如果要设计自己的着色器编译器或构造工具,并且想要有关着色器标记流的详细信息,请参阅 Direct3D 9 驱动程序开发工具包 (DDK) 。

类似于 C 的着色器语言

若要体验类似于 C 的着色器语言,请参阅 HLSL 参考

HLSL 参考