博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Asm Shader Reference --- Shader Model 2.0 part
阅读量:4450 次
发布时间:2019-06-07

本文共 4501 字,大约阅读时间需要 15 分钟。

ps部分

ps_2_0

概览

 

  Instruction Set              
                 
  Name Description Instruction slots Setup Arithmetic Texture New  
  绝对值 1   x   x  
  加法 1   x      
  Compare source to 0 1   x      
  叉积 2   x   x  
  为采样器声明贴图维数 0 x     x  
  声明顶点shader输出寄存器和像素shader输入寄存器之间的联合 0 x     x  
  定义常量 0 x        
  2D点积之后加法运算 2   x   x  
  3D点积 1   x      
  4D点积 1   x      
  全精度的2的x次方 1   x   x  
  小数部分 1   x   x  
  全精度的 log(x) 1   x   x  
  线性插值 2   x      
  3x2 乘法 2   x   x  
  3x3 乘法 3   x   x  
  3x4 乘法 4   x   x  
  4x3 乘法 3   x   x  
  4x4 乘法 4   x   x  
  乘法之后加法运算 1   x      
  最大值 1   x   x  
  最小值 1   x   x  
  赋值 1   x      
  乘法 1   x      
  无运算 1   x      
  单位化 3   x   x  
  幂运算 3   x   x  
  版本 0 x        
  倒数 1   x   x  
  平方根后倒数 1   x   x  
  sin和cos 8   x   x  
  减法 1   x      
  中断像素渲染 1     x    
  采样一张贴图 1     x x  
  根据w部分进行对贴图的level-of-detail bias采样 1     x x  
  根据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  
  绝对值 1   x   x  
  加法运算 1   x      
  调用一个子程序 2     x x  
  如果一个boolean寄存器不为0的话调用一个子程序 3     x x  
  叉积 2   x   x  
  0 x        
  定义常量 0 x        
  定义一个 Boolean 常量 0 x     x  
  定义一个integer 常量 0 x     x  
  3D 点积 1   x      
  4D 点积 1   x      
  计算距离向量 1   x      
  1     x x  
  endif - vs...else - vs block 1     x x  
  2     x x  
  结束一个 repeat block 2     x x  
  全精度计算2的幂 1   x      
  半精度计算2的幂 1   x      
  小数部分 1   x      
  if块 3     x x  
  Label 0     x x  
  局部光照计算 3   x      
  全精度计算log(x) 1   x      
  半精度计算log(x) 1   x      
  循环 3     x x  
  线性插值 2   x   x  
  3x2 乘法 2   x      
  3x3 乘法 3   x      
  3x4 乘法 4   x      
  4x3 乘法 3   x      
  4x4 乘法 4   x      
  乘法之后加法运算 1   x      
  最大值 1   x      
  最小值 1   x      
  赋值 1   x      
  从浮点寄存器到地址寄存器(a0)移动数据  1   x   x  
  乘法 1   x      
  无运算 1   x      
  单位化 3   x   x  
  幂运算 3   x   x  
  倒数 1   x      
  reapeat 3     x x  
  从主函数或子程序做return处理 1     x x  
  子程序的结束 1   x      
  平方根的倒数 1   x      
  Sign 3   x   x  
  Sin和cos 8   x   x  
  Less than compare 1   x      
  减法 1   x      
  版本 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

 

转载于:https://www.cnblogs.com/zhanlang96/p/6243732.html

你可能感兴趣的文章
HALCON标定板制作方法
查看>>
PAT 天梯赛 L1-009 N个数求和
查看>>
编码与解码
查看>>
java集合框架概述
查看>>
HP Vitrual Connect 配置快速参考
查看>>
ORA-04021等待锁定对象时超时
查看>>
Android学习笔记-事件处理机制
查看>>
阮一峰:为什么要写博客(转)
查看>>
Openstack_O版(otaka)部署_镜像服务glance部署
查看>>
28.openssl编程——CRL
查看>>
带分数(dfs,next_permutation)
查看>>
C++ string的用法和例子
查看>>
gcc g++编译问题。
查看>>
对nginx,uWSGI,django的理解
查看>>
反转一句话(仅反转各单词的顺序)
查看>>
P1546 最短网络(codevs | 2627村村通)
查看>>
502 Bad Gateway什么意思
查看>>
从接口测试谈游戏的自动化测试.
查看>>
ThinkGo:一个轻量级的 Go 语言 MVC 框架
查看>>
关于一个无极限分类的问题
查看>>