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 | ||||||
break_comp - ps | 通过一个比较跳出循环 | 3 | x | ||||||
breakp - ps | 基于一个断言跳出循环 | 3 | x | ||||||
call - ps | 调用一个子程序 | 2 | x | ||||||
callnz bool - ps | 如果一个boolean寄存器不为0的话调用一个子程序 | 3 | x | ||||||
callnz pred - ps | 如果一个predicate寄存器不为0的话调用一个子程序 | 3 | x | ||||||
cmp - ps | 以0为比较赋值 | 1 | x | ||||||
crs - ps | 叉积 | 2 | x | ||||||
dcl_samplerType (sm2, sm3 - ps asm) | 为采样器声明贴图维数 | 0 | x | ||||||
dcl_semantics (sm3 - ps asm) | 声明输入输出寄存器 | 0 | x | x | |||||
def - ps | 定义常量 | 0 | x | ||||||
defb - ps | 定义一个 Boolean 常量 | 0 | x | ||||||
defi - ps | 定义一个integer 常量 | 0 | x | ||||||
dp2add - ps | 2D 点积之后加法运算 | 2 | x | ||||||
dp3 - ps | 3D 点积 | 1 | x | ||||||
dp4 - ps | 4D 点积 | 1 | x | ||||||
dsx - ps | 改变x方向的比率 | 2 | x | ||||||
dsy - ps | 改变y方向的比率 | 2 | x | ||||||
else - ps | else块 | 1 | x | ||||||
endif - ps | if结束 | 1 | x | ||||||
endloop - ps | 结束loop | 2 | x | x | |||||
endrep - ps | 结束repeat | 2 | x | ||||||
exp - ps | 全精度计算2的幂 | 1 | x | ||||||
frc - ps | 小数部分 | 1 | x | ||||||
if bool - ps | if块 | 3 | x | ||||||
if_comp - ps | 比较形式的if | 3 | x | ||||||
if pred - ps | 断言形式的if | 3 | x | ||||||
label - ps | 标签 | 0 | x | ||||||
log - ps | 全精度计算log₂(x) | 1 | x | ||||||
loop - ps | 循环 | 3 | x | 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 | ||||||
ret - ps | 对主函数或子程序做return处理 | 1 | x | ||||||
rsq - ps | 平方根的倒数 | 1 | x | ||||||
setp_comp | 设置断言寄存器 | 1 | x | ||||||
sincos - ps | Sin和cos | 8 | x | ||||||
sub - ps | 减法运算 | 1 | x | ||||||
texkill - ps | 中断像素渲染 | 2 | x | ||||||
texld - ps_2_0 and up | 采样一个贴图 | See note 1 | x | ||||||
texldb - ps | 根据w部分进行对贴图的level-of-detail bias采样 | 6 | x | ||||||
texldl - ps | 根据来自w通道的level-of-detail来采样图片 | See note 2 | x | x | |||||
texldd - ps | 用户提供一个剃度值来采样贴图 | 3 | x | ||||||
texldp - ps | 根据w部分进行对贴图的投影划分采样 | See note 3 | x | ||||||
部分函数细节
dcl_semantics (sm3 - ps asm)
语法
dcl_semantics [_centroid] dst[.write_mask]
示例
ps_3_0
; Declaring inputs
dcl_normal v0.xyz
dcl_blendweight v0.w ; Must be same reg# as normal,matching vshader packing
dcl_texcoord1 v1.y ; Mask can be any subset of mask from vshader semantic
dcl_texcoord0 v1.zw; Has to be same reg# as texcoord1, to match vshader
; Declaring samplers
dcl_2d s0
dcl_2d s1
def c0, 0, 0, 0, 0
mov r0.x, v1.y ; texcoord1
mov r0.y, c0
texld r0, r0, s0
texld r1, v1.zw, s1
...
(output regs in ps_3_0 are same as ps_2_0: oC0-oC3,oDepth)
texldl - ps
语法
texldl dst, src0, src1
用于mipmap处理
算法
在mipmap滤波方式为linear时
LOD = src0.w + LODBIAS;
if (LOD <= 0 )
{
LOD = 0;
Filter =MagFilter;
tex = Lookup(MAX(MAXMIPLEVEL, LOD), Filter );
}
else
{
Filter =MinFilter;
LOD = MAX(MAXMIPLEVEL, LOD );
tex = Lookup(Floor(LOD), Filter );
if( MipFilter ==LINEAR )
{
tex1 =Lookup( Ceil(LOD), Filter );
tex = (1 -frac(src0.w))*tex + frac(src0.w)*tex1;
}
}
vs部分
概览
Instruction Set | |||||||||
Name | Description | Instruction slots | Setup | Arithmetic | Texture | Flow control | New | ||
abs - vs | 绝对值 | 1 | x | ||||||
add - vs | 加法运算 | 1 | x | ||||||
break - vs | 跳出一个循环 - vs...endloop - vs 或者 rep...endrep 块 | 1 | x | ||||||
break_comp - vs | 通过一个比较跳出循环 - vs...endloop - vs or rep...endrep block, with a comparison | 3 | x | ||||||
breakp - vs | 跳出一个循环 - vs...endloop - vs 或 rep...endrep 块, 基于一个断言 | 3 | x | ||||||
call - vs | 调用一个子程序 | 2 | x | ||||||
callnz bool - vs | 如果一个boolean寄存器不为0的话调用一个子程序 | 3 | x | ||||||
callnz pred - vs | 如果一个predicate寄存器不为0的话调用一个子程序 | 3 | x | ||||||
crs - vs | 叉积 | 2 | x | ||||||
dcl_usage input (sm1, sm2, sm3 - vs asm) | 为采样器声明贴图维数 | 0 | x | ||||||
dcl_samplerType (sm3 - vs asm) | 为采样器声明贴图维数 | 0 | x | 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 | Begin an else 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 | ||||||
if pred - vs | Begin an if bool - vs block with a predicate condition | 3 | 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 | 单位化 | 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 | ||||||
sge - vs | 大于等于比较 | 1 | x | ||||||
sgn - vs | 返回符号 | 3 | x | ||||||
sincos - vs | Sin和cos | 8 | x | ||||||
slt - vs | 小于比较 | 1 | x | ||||||
sub - vs | 减法 | 1 | x | ||||||
texldl - vs | 根据用户可调level-of-detail载入贴图 | See note 1 | x | x | |||||
vs | 版本 | 0 | x | ||||||
---wolf96 2017/1/3