Assembler/disassembler for the Xbox nv2a vertex shader
Project description
Trivial assembler for the nv2a vertex shader.
The Cg -> vp20 path performs various optimizations that sometimes make it hard to force unusual test conditions. This assembler performs no optimizations, and simply translates operands into machine code.
Instructions
-
ADD dst, src1, src2- Sum
dst = src1 + src2
- Sum
-
ARL a0, src- Load address register -
a0 = src
- Load address register -
-
DP3 dst, src1, src2- 3-component (xyz) dot product -
dst = src1 dotproduct_xyz src2
- 3-component (xyz) dot product -
-
DP4 dst, src1, src2- 4-component (xyzw) dot product -
dst = src1 dotproduct_xyzw src2
- 4-component (xyzw) dot product -
-
DPH dst, src1, src2- Homogenous dot product -
dst = src1.x * src2.x + src1.y * src2.y + src1.z * src2.z + src2.w
- Homogenous dot product -
-
DST dst, src1, src2- Compute distance vector.
src1.yzshould bedistance squared,src2.ywshould be1.0 / distance
dst.x = 1.0 dst.y = src1.y * src2.y dst.z = src1.z dst.w = src2.w - Compute distance vector.
-
EXPP dst, src-
Partial precision
2^xexponentiation.x_floor = floorf(src.x) dst.x = pow(2.0f, x_floor) dst.y = src.x - x_floor dst.z = pow(2.0f, src.x) dst.w = 1.0f
-
-
LIT dst, src-
Calculate lighting coefficients The src vector should be initialized with:
src.x = normal dotproduct direction_to_lightsrc.y = normal dotproduct light_half_vectorsrc.w = powerkMax = 127.9961f dst.x = 1.0f dst.y = 0.0f dst.z = 0.0f dst.w = 1.0f power = clamp(src.w, -kMax, kMax) if (src.x > 0.0f) { dst.x = src.x if (src.y > 0.0f) { dst.z = pow(src.y, power) } }
-
-
LOGP dst, src- Partial precision base 2 logarithm
dst.x = exponent dst.y = mantissa dst.z = log2(abs(src.x)) -
MAD dst, src1, src2, src3- Multiplies two sources, then adds a third.
dst = src1 * src2 + src3
- Multiplies two sources, then adds a third.
-
MAX dst, src1, src2- Returns the component-wise maximum between two vectors.
dst.C = max(src1.C, src2.C); for C in {x, y, z, w}
- Returns the component-wise maximum between two vectors.
-
MIN dst, src1, src2- Returns the component-wise minimum between two vectors.
dst.C = min(src1.C, src2.C); for C in {x, y, z, w}
- Returns the component-wise minimum between two vectors.
-
MOV dst, src- Assigns the value of one register to another.
dst = src
- Assigns the value of one register to another.
-
MUL dst, src1, src2- Multiply
dst = src1 * src2
- Multiply
-
RCC dst, src- Compute clamped reciprocal.
dst.xyzw = 1 / src[.x]clamped to ~(5.42101e-020f, 1.884467e+019)
- Compute clamped reciprocal.
-
RCP dst, src- Compute reciprocal.
dst.xyzw = 1 / src[.x]
- Compute reciprocal.
-
RSQ dst, src- Compute reciprocal of the square root.
dst.xyzw = 1 / sqrt(src[.x])
- Compute reciprocal of the square root.
-
SGE dst, src1, src2- Per component greater than or equal comparison.
dst.C = 1.0 if src1.C >= src2.C else 0.0; for C in {x, y, z, w}
- Per component greater than or equal comparison.
-
SLT dst, src1, src2- Per component less than comparison.
dst.C = 1.0 if src1.C < src2.C else 0.0; for C in {x, y, z, w}
- Per component less than comparison.
Registers
Temporary registers
r0-r11r12- read-only view of theoPosoutput register
Constant/uniform registers
c0-c191
Constant registers may also use relative addressing via bracket syntax. E.g.,
c[a0 + 12]
Address register
a0
May only be set via the ARL instruction. E.g., ARL a0, v12
Inputs
v0,iPosv1,iWeightv2,iNormalv3,iDiffusev4,iSpecularv5,iFogv6,iPtsv7,iBackDiffusev8,iBackSpecularv9,iTex0v10,iTex1v11,iTex2v12,iTex3v13v14v15
Outputs
oB0,oBackDiffuseoB1,oBackSpecularoD0,oDiffuseoD1,oSpecularoFogoPosoPtsoTex0,oT0oTex1,oT1oTex2,oT2oTex3,oT3
Swizzle/destination masks
xyzwrgba
Uniform macros
A simple macro syntax is supported to allow symbolic naming for c-register
access. Two types are currently implemented, vector and matrix4.
A vector type
aliases a single c register. E.g., to give a symbolic name to c10:
#uniform_name vector 10. The macro can then be used in subsequent
instructions; e.g., mov r0, #uniform_name.
A matrix4 type aliases a contiguous set of 4 c registers. E.g., to give a
symbolic name to a model matrix passed at 'c96': #my_model_matrix matrix4 96.
To access the second row: mul r0, v0.y, #my_model_matrix[1].
Operation macros
Higher level operations are supported via macros that expand to multiple instructions.
matmul4x4 - Multiply a 4 element vector by a 4x4 matrix
%matmul4x4 <dst> <read_register> <#matrix4_uniform>
Expands to 4 commands.
%matmul4x4 r0 iPos #model_matrix
------------------------------------
dp4 r0.x, iPos, #model_matrix[0]
dp4 r0.y, iPos, #model_matrix[1]
dp4 r0.z, iPos, #model_matrix[2]
dp4 r0.w, iPos, #model_matrix[3]
norm3 - Normalize a 3-component vector.
%norm3 <dst> <read_register> <read_write_temp_register>
Expands to 3 commands and requires one sacrificial register.
%norm3 r2 iNormal r0
------------------------------------
dp3 r0.x, iNormal, iNormal ; r0.x = len(normal)^2
rsq r0.w, r0.x ; r0.w = 1 / len(normal)
mul r2.xyz, iNormal, r0.w ; r2.xyz = normalized(normal)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nv2a_vsh-0.1.12.tar.gz.
File metadata
- Download URL: nv2a_vsh-0.1.12.tar.gz
- Upload date:
- Size: 67.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99f90241a38b210b51ecbbaa4d1033bd0d439830b59613e7fb4ea3d9634c92ba
|
|
| MD5 |
699a5e2f871ad784e67b2178ab47ed39
|
|
| BLAKE2b-256 |
cc16a81b3099293e630bdf9c67884cd74b8183c2a49a3759673967397aa7b2b6
|
File details
Details for the file nv2a_vsh-0.1.12-py3-none-any.whl.
File metadata
- Download URL: nv2a_vsh-0.1.12-py3-none-any.whl
- Upload date:
- Size: 64.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
263e5a4d00ba603c542b1a0628b01e972225792086c852aee24ba817e957a22a
|
|
| MD5 |
4d799fbd26b187ba4f63b955ef79fa61
|
|
| BLAKE2b-256 |
c06c2da879ff90e50bcdcc36c4dc38111030322c3624119b4b539f67d3f8ac4b
|