Shader Model 3 寄存器

292 篇文章 14 订阅
131 篇文章 3 订阅

http://msdn.microsoft.com/en-us/library/bb509656(v=VS.85).aspx

 

Registers - vs_3_0

This section contains reference information for the input and output registers implemented by vertex shader version 3_0.

Input Registers

RegisterNameCountR/W# Read ports# Reads / instDimensionRelAddrDefaultsRequires DCL
v#Input Register16R1Unlimited4a0/aLSee note 1Yes
r#Temporary Register32R/W3Unlimited4NoNoneNo
c#Constant Float RegisterSee note 2R1Unlimited4a0/aL(0, 0, 0, 0)No
a0Address Register1R/W1Unlimited4NoNoneNo
b#Constant Boolean Register16R111NoFALSENo
i#Constant Integer Register16R114No(0, 0, 0, 0)No
aLLoop Counter Register1R1Unlimited1NoNoneNo
p0Predicate Register1R/W114nononeno
s#Sampler (Direct3D 9 asm-vs)4R114NoSee note 3Yes

 

Notes:

  1. Partial (0, 0, 0, 1) - If only a subset of channels are updated, the remaining channels will default to (0, 0, 0, 1).
  2. Equal to D3DCAPS9.MaxVertexShaderConst (at least 256 for vs_3_0).
  3. Defaults for sampler lookup exist, but values depend on texture format.

Output Registers

Output registers have been collapsed into 12 o# (output) registers. These can be used for anything the user wants to interpolate for the pixel shader: texture coordinates, colors, fog, etc.

RegisterNameCountR/WDimensionRelAddrDefaultsRequires DCL
o#Output Register12W4aLNoneYes

 

 

 

 

 

 

ps_3_0 Registers

Pixel shaders depend on registers to get vertex data, to output pixel data, to hold temporary results during calculations, and to identify texture sampling stages. There are several types of registers, each with a unique functionality. This section contains reference information for the input and output registers implemented by pixel shader version 3_0.

New Registers

Input Register

The Input Registers (v#) are now fully floating point and the Texture Coordinate Registers (t#) have been consolidated into it. The dcl_semantics (sm3 - ps asm) at the top of the shader is used to describe what is containted in a particular Input_Register. A semantic for the pixel types is introduced (analogous to the vertex side) for this model. No clamping is performed when the input registers are defined as colors (like texture coordinates). The evaluation of the registers defined as color differs from the texture coordinates when multisampling.

Face Register

The face register (vFace) is new for this model. This is a floating point scalar register that will eventually contain the primitive area. In ps_3_0, however, only the sign of this register is valid. Hence, if the value is less than zero (the sign bit is set negative) the primitive is the back face (the area is negative, counterclockwise). Therefore, in ps_3_0 it only makes sense to compare this register against 0 (> 0 or < 0). Inside the pixel shader, the application can make a decision as to which lighting technique to use. Two-sided lighting can be achieved this way. This register requires a declaration, so undeclared usage will be flagged as an error. For lines and point primitives, this register is undefined. The face register can only be used as condition with the following instructions: setp_comp - ps, if_comp - ps, or break_comp - ps.

Loop Counter Register

The Loop Counter Register (aL) is new for this model. It automatically gets incremented in each execution of the loop - ps/endloop - ps block. It can be used in the block for relative addressing if needed. It is invalid to use Loop Counter Register outside the loop.

Position Register

The Position Register (vPos) is new for this model. It contains the current pixels (x, y) in the corresponding channels. The (z, w) channels are undefined. This register requires a declaration, so undeclared usage will be flagged as an error. When declared, this register must have exactly one of the following masks: .x, .y, .xy.

Input Register Types

RegisterNameCountR/W# Read ports# Reads/instDimensionRelAddrDefaultsRequires DCL
v#Input Register10R1Unlimited4aLNoneYes
r#Temporary Register32R/W3Unlimited4NoNoneNo
c#Constant Float Register224R1Unlimited4No0000No
i#Constant Integer Register16R114No0000No
b#Constant Boolean Register16R111NoFALSENo
p0Predicate Register1R111NoNoneNo
s#Sampler (Direct3D 9 asm-ps)16R114NoSee note 1Yes
vFaceFace_Register1R1Unlimited1NoNoneYes
vPosPosition_Register1R1Unlimited4NoNoneYes
aLLoop_Counter_Register1R1Unlimited1n/aNoneNo

 

Notes:

  • Defaults for sampler lookups exist, but values depend on texture format.

The number of readports is the number of different registers (for each register type) that can be read in a single instruction.

Output Register Types

RegisterNameCountR/WDimensionRelAddrDefaultsRequires DCL
oC#Output Color RegisterSee Multiple-element Textures (Direct3D 9)W4NoNoneNo
oDepthOutput Depth Register1W1NoNoneNo

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值