modern graphics hardware 2002 vertex programs joe michael kniss
Post on 20-Dec-2015
216 views
TRANSCRIPT
![Page 1: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/1.jpg)
Modern Graphics Hardware2002
Vertex ProgramsJoe Michael Kniss
![Page 2: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/2.jpg)
Overview
• Pipeline overview
• VP/FP overview
• Vertex Programs – Me
• Fragment Programs – Aaron
• Discussion
![Page 3: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/3.jpg)
Modern Graphics Hardware
Anti-Aliasing
Primitive construction Tessellation
Transform & Lighting
Transform to homogeneous eye space, light, texgen, deform…
Triangle setup View volume clip, view surface coordinates
Rasterization Generate fragments, interpolate color & texcoords
Fragment processing
Access textures, & compute final color
Tests Stencil, alpha, scissor, depth ….
Blending Add, mult, interpolate, max…
![Page 4: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/4.jpg)
Modern Graphics Hardware
Primitive construction
Transform & Lighting
Triangle setup
Rasterization
Fragment processing
Tests
Blending Anti-Aliasing
Pre--98
99
00 Vertex Programs 01
CombinersFragment Programs
Vertex Programs 2.0 02
Primitive Programs?
03?
Vertex Programs
Fragment Programs
![Page 5: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/5.jpg)
Higher order surfaces
Higher order surface
Transform & Lighting
Triangle setup
Rasterization
Fragment processing
Tests
Blending Anti-Aliasing
Vertex Programs
Fragment Programs
• PN Triangles (ATI)
•Bezier patches (NVIDIA)
![Page 6: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/6.jpg)
Vertex Programs
Higher order surface
Transform & Lighting
Triangle setup
Rasterization
Fragment processing
Tests
Blending Anti-Aliasing
Vertex Programs
Fragment Programs
16 inputvectors
256 staticvectors 12 temp
vectors
22 outputvectors
Post T&L cache
Loops
![Page 7: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/7.jpg)
Vertex 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
![Page 8: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/8.jpg)
Vertex Programs
• First generation (nv1.0, ati ext, ARB1.0)– 128 instructions– 96 constants– 12 temps– No loops
16 inputvectors
96 staticvectors 12 temp
vectors
15 outputvectors
Post T&L cache
![Page 9: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/9.jpg)
Vertex Programs
• First gen. inputs
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(TEXTURE1, ...) 10 texture coordinate set 2 MultiTexCoord(TEXTURE2, ...) 11 texture coordinate set 3 MultiTexCoord(TEXTURE3, ...) 12 texture coordinate set 4 MultiTexCoord(TEXTURE4, ...) 13 texture coordinate set 5 MultiTexCoord(TEXTURE5, ...) 14 texture coordinate set 6 MultiTexCoord(TEXTURE6, ...) 15 texture coordinate set 7 MultiTexCoord(TEXTURE7, ...) 8+n texture coordinate set n MultiTexCoord(TEXTURE0+n, ...)
![Page 10: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/10.jpg)
Vertex Programs
• First gen. inputs Conventional Attribute Binding Generic Attribute Binding ------------------------------ ------------------------- vertex.position vertex.attrib[0] vertex.weight vertex.attrib[1] vertex.weight[0] vertex.attrib[1] vertex.normal vertex.attrib[2] vertex.color vertex.attrib[3] vertex.color.primary vertex.attrib[3] vertex.color.secondary vertex.attrib[4] vertex.fogcoord vertex.attrib[5] vertex.texcoord vertex.attrib[8] vertex.texcoord[0] vertex.attrib[8] vertex.texcoord[1] vertex.attrib[9] vertex.texcoord[2] vertex.attrib[10] vertex.texcoord[3] vertex.attrib[11] vertex.texcoord[4] vertex.attrib[12] vertex.texcoord[5] vertex.attrib[13] vertex.texcoord[6] vertex.attrib[14] vertex.texcoord[7] vertex.attrib[15] vertex.texcoord[n] vertex.attrib[8+n]
ARB 1.0 notation (inputs == Read only)
![Page 11: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/11.jpg)
Vertex 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
![Page 12: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/12.jpg)
Vertex Programs
• First gen instruction set– Wow! That’s a lot of instructions– Why: SIMD processor– Single clock execution– Taken from ARB spec, not all instructions
available on all platforms
![Page 13: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/13.jpg)
Vertex Programs
• First gen. outputs
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.texcoord[n] (s,t,r,q) texture coordinate, unit n
ARB 1.0 notation (outputs == Write only??)
![Page 14: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/14.jpg)
Vertex Programs
• What’s special about the ARB 1.0 spec?– Unifies coding for multiple platforms
(That’s their job!)– Access to “tracked” OGL state
(Materials, Matrices,…)– Unifies vertex programs and next gen
fragment programs
![Page 15: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/15.jpg)
Vertex 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!!!
![Page 16: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/16.jpg)
Vertex Programs
• ARB 1.0 continued…– Vender specific “enhancements”– Access special functionality of chip– Use “OPTION BLAH” at top of program text
![Page 17: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/17.jpg)
Vertex 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!
![Page 18: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/18.jpg)
Vertex Programs
• ARB 1.0 example
!!ARBvp1.0
# comment here ;)
ATTRIB pos = vertex.position; #alias long names
ATTRIB norm = vertex.normal;
PARAM mv[4] = { state.matrix.modelview }; #alias
PARAM mvit[4] = { state.matrix.modelview.invtrans };
TEMP tnorm; # temp for the transformed normal
DP4 result.position.x mv[0] pos; # vertex to clip space
DP4 result.position.y mv[1] pos;
DP4 result.position.z mv[2] pos;
DP4 result.position.w mv[3] pos;
DP3 tnorm.x mvit[0] norm; # tranform the normal
DP3 tnorm.y mvit[1] norm; # for lighting (later)
DP3 tnorm.z mvit[2] norm;
…
![Page 19: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/19.jpg)
Vertex Programs
• Same example in Cg: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.modelview[0],(float3)IN.norm); … return out;}
![Page 20: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/20.jpg)
Vertex 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 inputvectors
256 staticvectors 12 temp
vectors
22 outputvectors
Post T&L cache
Loops
![Page 21: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/21.jpg)
Vertex 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)
![Page 22: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/22.jpg)
Vertex 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
![Page 23: Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss](https://reader033.vdocuments.pub/reader033/viewer/2022051516/56649d4c5503460f94a2b079/html5/thumbnails/23.jpg)
Questions?
… now on to Fragment Programs