Title: Modern Graphics Hardware 2002 Vertex Programs
1Modern Graphics Hardware2002Vertex Programs
2Overview
- Pipeline overview
- VP/FP overview
- Vertex Programs Me
- Fragment Programs Aaron
- Discussion
3Modern Graphics Hardware
4Modern Graphics Hardware
5Higher order surfaces
- PN Triangles (ATI)
- Bezier patches (NVIDIA)
6Vertex Programs
16 input vectors
256 static vectors
12 temp vectors
Loops
22 output vectors
Post TL cache
7Vertex Programs
- 3-5 flavors
- nv vertex programs 1.0 2.0
- ati vertex program (EXT)
- ARB vertex program 1.0 ( 2.0 ???)
- nv 1.0 ati ext ? ARB 1.0
- Next gen ARB 2.0 ????
- Closely matches Direct3D
8Vertex Programs
- First generation (nv1.0, ati ext, ARB1.0)
- 128 instructions
- 96 constants
- 12 temps
- No loops
16 input vectors
96 static vectors
12 temp vectors
15 output vectors
Post TL cache
9Vertex Programs
Generic Attribute Conventional
Attribute Conventional Attribute Command
--------- ------------------------
------------------------------ 0
vertex position Vertex 1
vertex weights 0-3 WeightARB,
VertexWeightEXT 2 normal
Normal 3 primary color
Color 4 secondary
color SecondaryColorEXT 5
fog coordinate FogCoordEXT
6 - -
7 - - 8
texture coordinate set 0
MultiTexCoord(TEXTURE0, ...) 9
texture coordinate set 1 MultiTexCoord(TEXTURE
1, ...) 10 texture coordinate set 2
MultiTexCoord(TEXTURE2, ...) 11
texture coordinate set 3 MultiTexCoord(TEXTURE
3, ...) 12 texture coordinate set 4
MultiTexCoord(TEXTURE4, ...) 13
texture coordinate set 5 MultiTexCoord(TEXTURE
5, ...) 14 texture coordinate set 6
MultiTexCoord(TEXTURE6, ...) 15
texture coordinate set 7 MultiTexCoord(TEXTURE
7, ...) 8n texture coordinate set n
MultiTexCoord(TEXTURE0n, ...)
10Vertex Programs
Conventional Attribute Binding Generic
Attribute Binding --------------------------
---- -------------------------
vertex.position
vertex.attrib0 vertex.weight
vertex.attrib1 vertex.weight0
vertex.attrib1
vertex.normal
vertex.attrib2 vertex.color
vertex.attrib3
vertex.color.primary
vertex.attrib3 vertex.color.secondary
vertex.attrib4
vertex.fogcoord
vertex.attrib5 vertex.texcoord
vertex.attrib8
vertex.texcoord0
vertex.attrib8 vertex.texcoord1
vertex.attrib9
vertex.texcoord2
vertex.attrib10 vertex.texcoord3
vertex.attrib11
vertex.texcoord4
vertex.attrib12 vertex.texcoord5
vertex.attrib13
vertex.texcoord6
vertex.attrib14 vertex.texcoord7
vertex.attrib15
vertex.texcoordn
vertex.attrib8n
ARB 1.0 notation (inputs Read only)
11Vertex Programs
- First gen instruction set
Instruction Inputs Output
Description ----------- ------ ------
-------------------------------- ABS
v v absolute value ADD
v,v v add ARL
v a address register load DP3
v,v ssss 3-component dot
product DP4 v,v ssss
4-component dot product DPH v,v
ssss homogeneous dot product DST
v,v v distance vector EX2
s ssss exponential base 2
EXP s v exponential
base 2 (approximate) FLR v
v floor FRC v v
fraction LG2 s ssss
logarithm base 2 LIT v v
compute light coefficients LOG
s v logarithm base 2
(approximate) MAD v,v,v v
multiply and add MAX v,v v
maximum MIN v,v v
minimum MOV v v
move MUL v,v v
multiply POW s,s ssss
exponentiate RCP s ssss
reciprocal RSQ s ssss
reciprocal square root SGE v,v
v set on greater than or equal SLT
v,v v set on less than
SUB v,v v subtract
SWZ v v extended swizzle
XPD v,v v cross
product
12Vertex Programs
- First gen instruction set
- Wow! Thats a lot of instructions
- Why SIMD processor
- Single clock execution
- Taken from ARB spec, not all instructions
available on all platforms
13Vertex Programs
Binding Components
Description -----------------------------
---------- ----------------------------
result.position (x,y,z,w)
position in clip coordinates result.color
(r,g,b,a) front-facing primary
color result.color.primary
(r,g,b,a) front-facing primary color
result.color.secondary (r,g,b,a)
front-facing secondary color
result.color.front (r,g,b,a)
front-facing primary color
result.color.front.primary (r,g,b,a)
front-facing primary color
result.color.front.secondary (r,g,b,a)
front-facing secondary color
result.color.back (r,g,b,a)
back-facing primary color
result.color.back.primary (r,g,b,a)
back-facing primary color
result.color.back.secondary (r,g,b,a)
back-facing secondary color result.fogcoord
(f,,,) fog coordinate
result.pointsize (s,,,) point
size result.texcoord
(s,t,r,q) texture coordinate, unit 0
result.texcoordn (s,t,r,q)
texture coordinate, unit n
ARB 1.0 notation (outputs Write only??)
14Vertex Programs
- Whats special about the ARB 1.0 spec?
- Unifies coding for multiple platforms (Thats
their job!) - Access to tracked OGL state
(Materials, Matrices,) - Unifies vertex programs and next gen fragment
programs
15Vertex Programs
- ARB 1.0 continued
- Position invariant vertex programs
- Use the fixed function pipe to transform vertices
- You still do the lighting
- Same transformation even if vertex program
enabled - Option set in VP text file
- KEY for multi-pass algorithms!!!
16Vertex Programs
- ARB 1.0 continued
- Vender specific enhancements
- Access special functionality of chip
- Use OPTION BLAH at top of program text
17Vertex Programs
- Other ARB 1.0 features
- Constant scoping, env, state, local
- Determines life time update behavior
- Temporary aliasing (tmp1 tmp2)
- Automatic constant management, let driver deal
with constant numbering!
18Vertex Programs
!!ARBvp1.0 comment here ) ATTRIB pos
vertex.position alias long names ATTRIB norm
vertex.normal PARAM mv4
state.matrix.modelview alias PARAM mvit4
state.matrix.modelview.invtrans TEMP
tnorm temp for the transformed normal DP4
result.position.x mv0 pos vertex to clip
space DP4 result.position.y mv1 pos DP4
result.position.z mv2 pos DP4
result.position.w mv3 pos DP3 tnorm.x mvit0
norm tranform the normal DP3 tnorm.y mvit1
norm for lighting (later) DP3 tnorm.z
mvit2 norm
19Vertex Programs
struct appin application2vertex float4 pos
POSITION float4 Norm NORMAL struct
vertout vertex2fragment float4 HPos
POSITION float4 PCol COLOR0 vertout
main(appin IN) vertout out out.Hpos
mul(glstate.matrix.mvp, IN.pos) // note
cast to float3 for the normal!!!! float3
tnorm mul(glstate.matrix.invtrans.modelview0,
(float3)IN.norm) return out
20Vertex Programs
- Next generation (nv2.0, ati ?, ARB2.0?)
- 256 instructions
- 256 constants
- 12 temps ?
- Loops
- Subroutines
- Conditional branching
- 4 address registers
- 6 clips 8 textures
16 input vectors
256 static vectors
12 temp vectors
Loops
22 output vectors
Post TL cache
21Vertex Programs
- Next gen vertex programs
- True conditional branching, looping and
subroutine calls - Conditional write masks
- Enhanced instruction set
(frac, floor, sin, cos, ex2, lg2,
pow, lerp) - More everything vs. NV2X
- instructions (from 128 to 256)
- constants (from 96 to 256)
- address registers (from 1 to 4)
- texture coordinate sets (from 4 to 8)
- clip planes (from 0 to 6)
22Vertex Programs
- ARB vp2.0 not ratified yet
- Have to use vendor specifics till then
- Who knows when???
- Still follows Direct3D, no problem??
- Need uniformity for programmers sake
23Questions?
- now on to Fragment Programs