Asm Shader Reference --- Shader Model 2.0 part
ps部分
ps_2_0
概览
| Instruction Set | ||||||||
| Name | Description | Instruction slots | Setup | Arithmetic | Texture | New | ||
| abs - ps | 绝对值 | 1 | x | x | ||||
| add - ps | 加法 | 1 | x | |||||
| cmp - ps | Compare source to 0 | 1 | x | |||||
| crs - ps | 叉积 | 2 | x | x | ||||
| dcl_samplerType (sm2, sm3 - ps asm) | 为采样器声明贴图维数 | 0 | x | x | ||||
| dcl - (sm2, sm3 - ps asm) | 声明顶点shader输出寄存器和像素shader输入寄存器之间的联合 | 0 | x | x | ||||
| def - ps | 定义常量 | 0 | x | |||||
| dp2add - ps | 2D点积之后加法运算 | 2 | x | x | ||||
| dp3 - ps | 3D点积 | 1 | x | |||||
| dp4 - ps | 4D点积 | 1 | x | |||||
| exp - ps | 全精度的2的x次方 | 1 | x | x | ||||
| frc - ps | 小数部分 | 1 | x | x | ||||
| log - ps | 全精度的 log₂(x) | 1 | x | x | ||||
| lrp - ps | 线性插值 | 2 | x | |||||
| m3x2 - ps | 3x2 乘法 | 2 | x | x | ||||
| m3x3 - ps | 3x3 乘法 | 3 | x | x | ||||
| m3x4 - ps | 3x4 乘法 | 4 | x | x | ||||
| m4x3 - ps | 4x3 乘法 | 3 | x | x | ||||
| m4x4 - ps | 4x4 乘法 | 4 | x | x | ||||
| mad - ps | 乘法之后加法运算 | 1 | x | |||||
| max - ps | 最大值 | 1 | x | x | ||||
| min - ps | 最小值 | 1 | x | x | ||||
| mov - ps | 赋值 | 1 | x | |||||
| mul - ps | 乘法 | 1 | x | |||||
| nop - ps | 无运算 | 1 | x | |||||
| nrm - ps | 单位化 | 3 | x | x | ||||
| pow - ps | 幂运算 | 3 | x | x | ||||
| ps | 版本 | 0 | x | |||||
| rcp - ps | 倒数 | 1 | x | x | ||||
| rsq - ps | 平方根后倒数 | 1 | x | x | ||||
| sincos - ps | sin和cos | 8 | x | x | ||||
| sub - ps | 减法 | 1 | x | |||||
| texkill - ps | 中断像素渲染 | 1 | x | |||||
| texld - ps_2_0 and up | 采样一张贴图 | 1 | x | x | ||||
| texldb - ps | 根据w部分进行对贴图的level-of-detail bias采样 | 1 | x | x | ||||
| texldp - ps | 根据w部分进行对贴图的投影划分采样 | 1 | x | x | ||||
部分函数细节
crs
语法
crs dst, src0, src1
叉积
算法
dest.x = src0.y * src1.z - src0.z * src1.y;
dest.y = src0.z * src1.x - src0.x * src1.z;
dest.z = src0.x * src1.y - src0.y * src1.x;
dcl_samplerType
语法
dcl_samplerType s#
声明一个像素shader采样器
· _2d
· _cube
· _volume
示例
dcl_cube t0.rgb; // Define a 3D texture map.
add r0, r0, t0; // Perturb texture coordinates.
texld r0, s0, r0; // Load r0 with a color sampled from stage0
// at perturbed texture coordinates r0.
// This is a dependent texture read.
dp2add
语法
dp2add dst, src0, src1, src2.{x|y|z|w}
算法
dest = src0.r * src1.r + src0.g * src1.g + src2.replicate_swizzle
// The scalar result is replicated to the write mask components
nrm
语法
nrm dst, src
单位化一个3D向量
squareRootOfTheSum = (src0.x*src0.x + src0.y*src0.y +src0.z*src0.z)1/2;
算法
dest.x = src0.x * (1 / squareRootOfTheSum);
dest.y = src0.y * (1 / squareRootOfTheSum);
dest.z = src0.z * (1 / squareRootOfTheSum);
dest.w = src0.w * (1 / squareRootOfTheSum);
sincos
语法
ps_2_0 和 ps_2_x
sincos dst.{x|y|xy}, src0.{x|y|z|w}, src1, src2
ps_3_0
sincos dst.{x|y|xy}, src0.{x|y|z|w}
算法
ps_2_0 and ps_2_x
写入通道为.x
dest.x = cos(V)
dest.y is undefined when the instruction completes
dest.z is undefined when the instruction completes
dest.w is not touched by the instruction
写入通道为.y
dest.x is undefined when the instruction completes
dest.y = sin(V)
dest.z is undefined when the instruction completes
dest.w is not touched by the instruction
写入通道为.xy
dest.x = cos(V)
dest.y = sin(V)
dest.z is undefined when the instruction completes
dest.w is not touched by the instruction
ps_3_0
写入通道为.x
dest.x = cos(V)
dest.y is undefined when the instruction completes
dest.z is undefined when the instruction completes
dest.w is not touched by the instruction
写入通道为.y
dest.x is undefined when the instruction completes
dest.y = sin(V)
dest.z is undefined when the instruction completes
dest.w is not touched by the instruction
写入通道为.xy
dest.x = cos(V)
dest.y = sin(V)
dest.z is undefined when the instruction completes
dest.w is not touched by the instruction
示例角度制转弧度制
def c0, pi, 0.5, 2*pi, 1/(2*pi)
mad r0.x, input_angle, c0.w, c0.y
frc r0.x, r0.x
mad r0.x, r0.x, c0.z, -c0.x
vs部分
vs_2_0
概览
| Instruction Set | ||||||||
| Name | Description | Instruction slots | Setup | Arithmetic | Flow control | New | ||
| abs - vs | 绝对值 | 1 | x | x | ||||
| add - vs | 加法运算 | 1 | x | |||||
| call - vs | 调用一个子程序 | 2 | x | x | ||||
| callnz bool - vs | 如果一个boolean寄存器不为0的话调用一个子程序 | 3 | x | x | ||||
| crs - vs | 叉积 | 2 | x | x | ||||
| dcl_usage input (sm1, sm2, sm3 - vs asm) | 声明输入顶点寄存器(see Registers - vs_2_0) | 0 | x | |||||
| def - vs | 定义常量 | 0 | x | |||||
| defb - vs | 定义一个 Boolean 常量 | 0 | x | x | ||||
| defi - vs | 定义一个integer 常量 | 0 | x | x | ||||
| dp3 - vs | 3D 点积 | 1 | x | |||||
| dp4 - vs | 4D 点积 | 1 | x | |||||
| dst - vs | 计算距离向量 | 1 | x | |||||
| else - vs | else - vs block | 1 | x | x | ||||
| endif - vs | endif - vs...else - vs block | 1 | x | x | ||||
| endloop - vs | 结束一个循环 - vs block | 2 | x | x | ||||
| endrep - vs | 结束一个 repeat block | 2 | x | x | ||||
| exp - vs | 全精度计算2的幂 | 1 | x | |||||
| exp - vs | 半精度计算2的幂 | 1 | x | |||||
| frc - vs | 小数部分 | 1 | x | |||||
| if bool - vs | if块 | 3 | x | x | ||||
| label - vs | Label | 0 | x | x | ||||
| lit - vs | 局部光照计算 | 3 | x | |||||
| log - vs | 全精度计算log₂(x) | 1 | x | |||||
| logp - vs | 半精度计算log₂(x) | 1 | x | |||||
| loop - vs | 循环 | 3 | x | x | ||||
| lrp - vs | 线性插值 | 2 | x | 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 | x | ||||
| mul - vs | 乘法 | 1 | x | |||||
| nop - vs | 无运算 | 1 | x | |||||
| nrm - vs | 单位化 | 3 | x | x | ||||
| pow - vs | 幂运算 | 3 | x | x | ||||
| rcp - vs | 倒数 | 1 | x | |||||
| rep - vs | reapeat | 3 | x | x | ||||
| ret - vs | 从主函数或子程序做return处理 | 1 | x | x | ||||
| rsq - vs | 子程序的结束 | 1 | x | |||||
| sge - vs | 平方根的倒数 | 1 | x | |||||
| sgn - vs | Sign | 3 | x | x | ||||
| sincos - vs | Sin和cos | 8 | x | x | ||||
| slt - vs | Less than compare | 1 | x | |||||
| sub - vs | 减法 | 1 | x | |||||
| vs | 版本 | 0 | x | |||||
部分函数细节
mova
语法
mova dst, src
dst必须是地址寄存器,a0
示例
将浮点数赋值到整数寄存器,转换要使用凑整函数
if(dest is an integer register)
{
int intSrc =RoundToNearest(src);
dest = intSrc;
}
else
{
dest = src;
}
在2_x或以上版本,地址寄存器是部分向量,写入任何通道都可以
mova a0.xz, r0
sge
语法
sgedst, src0, src1
逐通道比较 src0与src1,如果src0大于等于src1返回1否则返回0
算法
dest.x = (src0.x>= src1.x) ? 1.0f : 0.0f;
dest.y = (src0.y>= src1.y) ? 1.0f : 0.0f;
dest.z = (src0.z>= src1.z) ? 1.0f : 0.0f;
dest.w = (src0.w>= src1.w) ? 1.0f : 0.0f;
sgn
语法
sgn dst, src0, src1
返回src0的符号
src1, src2为临时寄存器保存中间计算过程,为未定义
算法
for each component in src0
{
if(src0.component < 0)
dest.component= -1;
else
if(src0.component == 0)
dest.component = 0;
else
dest.component = 1;
}
slt
语法
slt dst, src0, src1
与sge相反,逐通道比较src0与src1,如果src0小于src1返回1否则返回0
算法
dest.x = (src0.x < src1.x) ? 1.0f : 0.0f;
dest.y = (src0.y < src1.y) ? 1.0f : 0.0f;
dest.z = (src0.z < src1.z) ? 1.0f : 0.0f;
dest.w = (src0.w < src1.w) ? 1.0f : 0.0f;
-----wolf96 2017/1/3
Asm Shader Reference --- Shader Model 2.0 part的更多相关文章
- Asm Shader Reference --- Shader Model 2.x part
ps部分 概览 Instruction Set Name Description Instruction slots S ...
- Asm Shader Reference --- Shader Model 3.0 part
ps部分 概览 Instruction Set Name Description Instruction slots S ...
- Asm Shader Reference --- Shader Model 1 part
ps部分 ps_1_1,ps_1_2,ps_1_3,ps_1_4 总览 Instruction Set ...
- 微软的HLSL Shader Model 6.0 compiler要转向LLVM了,开源的节奏. Apple/Khronos都有各自计划
So, Microsoft is making an opensource HLSL-to-almost-LLVM compiler, and Khronos is making an opensou ...
- Shader Model 3.0:Using Vertex Textures SM3:使用顶点纹理 (NVIDIA spec, 6800支持使用D3DFMT_R32F and D3DFMT_A32B32G32R32F的纹理格式实现Vertex Texture。)
翻译者 周波 zhoubo22@hotmail.com 版权所有 Philipp Gerasimov Randima (Randy) Fernando Simon Green NVIDIA Corpo ...
- Unity3D for VR 学习(9): Unity Shader 光照模型 (illumination model)
关于光照模型 所谓模型,一般是由学术算法发起, 经过大量实际数据验证而成的可靠公式 现在还记得2009年做TD-SCDMA移动通信算法的时候,曾经看过自由空间传播模型(Free space propa ...
- ePass1000 Full ActiveX Control Reference Manual Version 2.0
ePass1000 Full ActiveX Control Reference Manual Version 2.0 Error Code Value Return Status Descripti ...
- caffe编译时候出现 undefined reference to `TIFFReadRGBAStrip@LIBTIFF_4.0'
1.编译时候出现 make: * [.build_release/examples/siamese/convert_mnist_siamese_data.bin] Error 1 /usr/local ...
- Create a Basic Shader in Shader Forge
[Create a Basic Shader in Shader Forge] 1.打开ShaderForge.Window-> Shader Forge.(打开速度较慢) 2.通过NewSha ...
随机推荐
- [DevExpress]SplitContainerControl使用小计
1.修改成纵向分割 Horizontal = false; 2.设置伸缩箭头 3.固定某个PANEL大小 最大化后依然保持着比例 4.隐藏某个PANEL splitContainerControl1. ...
- 利用Keepalived+mysql构建高可用MySQL双主自动切转
转载:http://www.it300.com/index.php/article-15266.html 关于MySQL-HA,目前有多种解决方案,比如heartbeat.drbd.mmm.共享存储, ...
- json在线校验
弄了一个在线校验,清爽无广告,欢迎大家收藏 http://www.zhhoney.com/
- .Net 平台下的互联网架构新思考
上一篇<互联网应用架构谈>有很多阅读量,但后来实践中发现基于WCF服务层技术用于实现网站访问的效率是有问题的. 我的本意是以WCF中间层解决商业逻辑,供各个平台调用,然而还是带来诸多的麻烦 ...
- linux下定时发送邮件
at命令可以在某个时间运行某个程序,而mail可以以命令行的方式把存于一个文本中的邮件正文发送抄送出去. 具体用法: 1. 把email正文准备好,比如写在email.txt里 2. 然后写一个脚 ...
- Centos 6.4上面用Shell脚本一键安装vsftpd
Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...
- gei shilei d
body, p { margin: 0; padding: 0; font-size: 16px; } div { margin: 0 auto; } .wrapper { width: 1080px ...
- [DP] Rod-cutting problem
给一个长度为 n 的杆子,切成小段卖出去,价格根据小段的长度不同而不同.下面是一个例子 我们要通过切成小段卖出尽可能高的总价钱.问题是:How to decompose the problem? De ...
- Percona Xtrabackup备份mysql全库及指定数据库(完整备份与增量备份)
原文地址:http://www.tuicool.com/articles/RZRnq2 Xtrabackup简介 Percona XtraBackup是开源免费的MySQL数据库热备份软件,它能对In ...
- Dojo Widget系统(转)
Dojo 里所有的小部件(Widget)都会直接或间接的继承 dijit._Widget / dijit._WidgetBase dijit._Widget 是 dojo 1.6 和 1.6之前的版本 ...