Asm Shader Reference --- Shader Model 2.x part
ps部分
概览
Instruction Set | |||||||||
Name | Description | Instruction slots | Setup | Arithmetic | Texture | Flow control | New | ||
abs - ps | 绝对值 | 1 | x | ||||||
add - ps | 加法运算 | 1 | x | ||||||
break - ps | 跳出一个循环 | 1 | x | x | |||||
break_comp - ps | 通过一个比较跳出循环 | 3 | x | x | |||||
breakp - ps | 基于一个断言跳出循环 | 3 | x | x | |||||
call - ps | 调用一个子程序 | 2 | x | x | |||||
callnz bool - ps | 如果一个boolean寄存器不为0的话调用一个子程序 | 3 | x | x | |||||
callnz pred - ps | 如果一个predicate寄存器不为0的话调用一个子程序 | 3 | x | x | |||||
cmp - ps | 以0为比较赋值 | 1 | x | ||||||
crs - ps | 叉积 | 2 | x | ||||||
dcl_samplerType (sm2, sm3 - ps asm) | 为采样器声明贴图维数 | 0 | x | ||||||
dcl - (sm2, sm3 - ps asm) | 声明顶点shader输出寄存器和像素shader输入寄存器之间的联合 | 0 | x | ||||||
def - ps | 定义常量 | 0 | x | ||||||
defb - ps | 定义一个 Boolean 常量 | 0 | x | x | |||||
defi - ps | 定义一个integer 常量 | 0 | x | x | |||||
dp2add - ps | 2D 点积之后加法运算 | 2 | x | ||||||
dp3 - ps | 3D 点积 | 1 | x | ||||||
dp4 - ps | 4D 点积 | 1 | x | ||||||
dsx - ps | 改变x方向的比率 | 2 | x | x | |||||
dsy - ps | 改变y方向的比率 | 2 | x | x | |||||
else - ps | else块 | 1 | x | x | |||||
endif - ps | if结束 | 1 | x | x | |||||
endrep - ps | 循环结束 | 2 | x | x | |||||
exp - ps | 全精度计算2的幂 | 1 | x | ||||||
frc - ps | 小数部分 | 1 | x | ||||||
if bool - ps | if块 | 3 | x | x | |||||
if_comp - ps | 比较形式的if | 3 | x | x | |||||
if pred - ps | 断言形式的if | 3 | x | x | |||||
label - ps | 标签 | 0 | x | x | |||||
log - ps | 全精度计算log₂(x) | 1 | x | ||||||
lrp - ps | 线性插值 | 2 | x | ||||||
m3x2 - ps | 3x2 乘法 | 2 | x | ||||||
m3x3 - ps | 3x3 乘法 | 3 | x | ||||||
m3x4 - ps | 3x4 乘法 | 4 | x | ||||||
m4x3 - ps | 4x3 乘法 | 3 | x | ||||||
m4x4 - ps | 4x4 乘法 | 4 | x | ||||||
mad - ps | 乘法之后加法运算 | 1 | x | ||||||
max - ps | 最大值 | 1 | x | ||||||
min - ps | 最小值 | 1 | x | ||||||
mov - ps | 赋值 | 1 | x | ||||||
mul - ps | 乘法 | 1 | x | ||||||
nop - ps | 无运算 | 1 | x | ||||||
nrm - ps | 单位化 | 3 | x | ||||||
pow - ps | 幂运算 | 3 | x | ||||||
ps | 版本 | 0 | x | ||||||
rcp - ps | 倒数 | 1 | x | ||||||
rep - ps | 循环 | 3 | x | x | |||||
ret - ps | 子程序的结束 | 1 | x | x | |||||
rsq - ps | 平方根的倒数 | 1 | x | ||||||
setp_comp | 设置断言寄存器 | 1 | x | x | |||||
sincos - ps | Sin和cos | 8 | x | ||||||
sub - ps | 减法运算 | 1 | x | ||||||
texkill - ps | 中断像素渲染 | See note 1 | x | ||||||
texld - ps_2_0 and up | 采样一个贴图 | See note 2 | x | ||||||
texldb - ps | 根据w部分进行对贴图的level-of-detail bias采样 | See note 3 | x | ||||||
texldd - ps | 用户提供一个剃度值来采样贴图 | 3 | x | x | |||||
texldp - ps | 根据w部分进行对贴图的投影划分采样 | See note 4 | x | ||||||
部分函数细节
endrep
语法
endrep
示例
rep i2
add r0, r0, c0
endrep
if bool
if bool
示例
defb b3, true
if b3
// Instructions to run if b3 is nonzero
else
// Instructions to run otherwise
endif
if_comp
语法
if_comp src0, src1
_comp为
Syntax |
Comparison |
_gt |
大于 |
_lt |
小于 |
_ge |
大于等于 |
_le |
小于等于 |
_eq |
等于 |
_ne |
不等于 |
示例
if_lt r3.x, r4.y
// Instructions to run if r3.x < r4.y
else
// Instructions to run otherwise
endif
rep
语法
rep i#
循环
i#.x范围为[0, 255]
示例
rep i2
add r0, r0, c0
endrep
vs部分
概览
Instruction Set | ||||||||
Name | Description | Instruction slots | Setup | Arithmetic | Flow control | New | ||
abs - vs | 绝对值 | 1 | x | |||||
add - vs | 加法运算 | 1 | x | |||||
break - vs | 跳出一个循环 - vs...endloop - vs 或者 rep...endrep 块 | 1 | x | x | ||||
break_comp - vs | 通过一个比较跳出循环 - vs...endloop - vs or rep...endrep block, with a comparison | 3 | x | x | ||||
breakp - vs | 跳出一个循环 - vs...endloop - vs 或 rep...endrep 块, 基于一个断言 | 3 | x | x | ||||
call - vs | 调用一个子程序 | 2 | x | |||||
callnz bool - vs | 如果一个boolean寄存器不为0的话调用一个子程序 | 3 | x | |||||
callnz pred - vs | 如果一个predicate寄存器不为0的话调用一个子程序 | 3 | x | x | ||||
crs - vs | 叉积 | 2 | x | |||||
dcl_usage input (sm1, sm2, sm3 - vs asm) | 为采样器声明贴图维数 | 0 | x | |||||
def - vs | 定义常量 | 0 | x | |||||
defb - vs | 定义一个 Boolean 常量 | 0 | x | |||||
defi - vs | 定义一个integer 常量 | 0 | x | |||||
dp3 - vs | 3D 点积 | 1 | x | |||||
dp4 - vs | 4D 点积 | 1 | x | |||||
dst - vs | 计算距离向量 | 1 | x | |||||
else - vs | else - vs block | 1 | x | |||||
endif - vs | 结束if - vs...else - vs block | 1 | x | |||||
endloop - vs | 结束循环 - vs block | 2 | x | |||||
endrep - vs | 结束 repeat 块 | 2 | x | |||||
exp - vs | 全精度计算2的幂 | 1 | x | |||||
exp - vs | 半精度计算2的幂 | 1 | x | |||||
frc - vs | 小数部分 | 1 | x | |||||
if bool - vs | Begin an if bool - vs block (using a Boolean condition) | 3 | x | |||||
if_comp - vs | Begin an if bool - vs block, with a comparison | 3 | x | x | ||||
if pred - vs | Begin an if bool - vs block with a predicate condition | 3 | x | x | ||||
label - vs | 标签 | 0 | x | |||||
lit - vs | 局部光照计算 | 3 | x | |||||
log - vs | 全精度计算log₂(x) | 1 | x | |||||
logp - vs | 半精度计算log₂(x) | 1 | x | |||||
loop - vs | 循环 | 3 | x | |||||
lrp - vs | 线性插值 | 2 | x | |||||
m3x2 - vs | 3x2 乘法 | 2 | x | |||||
m3x3 - vs | 3x3 乘法 | 3 | x | |||||
m3x4 - vs | 3x4 乘法 | 4 | x | |||||
m4x3 - vs | 4x3 乘法 | 3 | x | |||||
m4x4 - vs | 4x4 乘法 | 4 | x | |||||
mad - vs | 乘法之后加法运算 | 1 | x | |||||
max - vs | 最大值 | 1 | x | |||||
min - vs | 最小值 | 1 | x | |||||
mov - vs | 赋值 | 1 | x | |||||
mova - vs | 从浮点寄存器到地址寄存器(a0)移动数据 | 1 | x | |||||
mul - vs | 乘法 | 1 | x | |||||
nop - vs | 无运算 | 1 | x | |||||
nrm - vs | 单位化一个 4D 向量 | 3 | x | |||||
pow - vs | 幂运算 | 3 | x | |||||
rcp - vs | 倒数 | 1 | x | |||||
rep - vs | 循环 | 3 | x | |||||
ret - vs | 对主函数或子程序做return处理 | 1 | x | |||||
rsq - vs | 平方根的倒数 | 1 | x | |||||
setp_comp - vs | 设置断言寄存器 | 1 | x | x | ||||
sge - vs | 大于等于比较 | 1 | x | |||||
sgn - vs | 返回符号 | 3 | x | |||||
sincos - vs | Sin和cos | 8 | x | |||||
slt - vs | 小于比较 | 1 | x | |||||
sub - vs | 减法 | 1 | x | |||||
vs | 版本 | 0 | x | |||||
---wolf96 2017/1/3