Where does the Vertex Engine fit? - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Where does the Vertex Engine fit?

Description:

Can be used to track OpenGl matrices (modelview, projection, texture, etc.) Example: ... LIT instruction implements phong lighting. Dot Product Instruction. DP3 ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 23
Provided by: Comdex
Learn more at: https://cse.osu.edu
Category:
Tags: engine | fit | lighting | track | vertex

less

Transcript and Presenter's Notes

Title: Where does the Vertex Engine fit?


1
Where does the Vertex Engine fit?
Transform Lighting
Traditional Graphics Pipeline
setup rasterizer
texture blending
frame-buffer anti-aliasing
2
GeForce 3 Vertex Engine
Vertex Program
Transform Lighting
setup rasterizer
texture blending
frame-buffer anti-aliasing
3
API Support
  • Designed to fit into OpenGL and D3D APIs
  • Program mode vs. Fixed function mode
  • Load and bind program
  • Simple to add to old D3D and OpenGL programs

4
Programming Model
  • Enable vertex program
  • glEnable(GL_VERTEX_PROGRAM_NV)
  • Create vertex program object
  • Bind vertex program object
  • Execute vertex program object

5
Create Vertex Program
  • Programs (assembly) are defined inline as
  • character strings

static const GLubyte vpgm \!!VP1. 0\ DP4
oHPOS.x, c0, v0 \ DP4
oHPOS.y, c1, v0 \ DP4
oHPOS.z, c2, v0 \ DP4
oHPOS.w, c3, v0 \ MOV
oCOL0,v3
\ END"
6
Create Vertex Program (2)
  • Load and bind vertex programs similar to texture
    objects
  • glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 7,
    strelen(programString), programString)
  • .
  • glBindProgramNV(GL_VERTEX_PROGRAM_NV, 7)

7
Invoke Vertex Program
  • The vertex program is invoked when a vertex is
    given, i.e., when
  • glBegin()
  • glVertex3f(x,y,z)
  • glEnd()

8
Lets look at a sample program
static const GLubyte vpgm \!!VP1. 0\ DP4
oHPOS.x, c0, v0 \ DP4
oHPOS.y, c1, v0 \ DP4
oHPOS.z, c2, v0 \ DP4
oHPOS.w, c3, v0 \ MOV
oCOL0,v3
\ END"
OHPOS M(c0,c1,c2,c3) v - HPOS? OCOL0
v3 - COL0? Calculate
the clip space point position and Assign the
vertex with v3 for its diffuse color
9
Programming Model
V0 V15
Vertex Source
Program Constants
c0 c96
16x4 registers
OHPOS OCOL0 OCOL1 OFOGP OPSIZ OTEX0
OTEX7
Vertex Program
96x4 registers
R0 R11
Temporary Registers
128 instructions
12x4 registers
Vertex Output
15x4 registers
All quad floats
10
Input Vertex Attributes
  • V0 V15
  • Aliased (tracked) with conventional per-vertex
    attributes (Table 3)
  • Use glVertexAttribNV() to explicitly assign
    values
  • Can also specify a scalar value to the vertex
    attribute array - glVertexAttributesNV()
  • Can change values inside or outside
    glBegin()/glEnd() pair

11
Program Constants
  • Can only change values outside glBegin()/glEnd()
    pair
  • No automatic aliasing
  • Can be used to track OpenGl matrices (modelview,
    projection, texture, etc.)
  • Example
  • glTrackMatrix(GL_VERTEX_PROGRAM_NV, 0,
    GL_MODELVIEW_PROJECTION_NV, GL_IDENTIGY_NV)
  • Track 4 contiguous program constants starting
    with c0

12
Program Constants (contd)
  • DP4 oHPOS.x, c0, vOPOS
  • DP4 oHPOS.y, c1, vOPOS
  • DP4 oHPOS.z, c2, vOPOS
  • DP4 oHPOS.w, c3, vOPOS
  • What does it do?

13
Program Constants (contd)
  • glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4,
    GL_MODEL_VIEW, GL_INVERSE_TRANPOSE_NV)
  • DP3 R0.x, C4, VNRML
  • DP3 R0.y, C5, VNRML
  • DP3 R0.z, C6, VNRML
  • What doe it do?

14
Hardware Block Diagram
Vertex In
Vertex Attribute Buffer (VAB)
Vector FP Core
Vertex Out
15
Data Path
X
Y
Z
W
X
Y
Z
W
X
Y
Z
W
Swizzle
Swizzle
Swizzle
Negate
Negate
Negate
FPU Core
Write Mask
X
Y
Z
W
16
Instruction Set The ops
  • 17 instructions total
  • MOV, MUL, ADD, MAD, DST
  • DP3, DP4
  • MIN, MAX, SLT, SGE
  • RCP, RSQ, LOG, EXP, LIT
  • ARL

17
Instruction Set The Core Features
  • Immediate access to sources
  • Swizzle/negate on all sources
  • Write mask on all destinations
  • DP3,DP4 most common graphics ops
  • Cross product is MULMAD with swizzling
  • LIT instruction implements phong lighting

18
Dot Product Instruction
  • DP3 R0.x, R1, R2 -
  • R0.x R1.x R2.x R1.y R1.y R1.z R2.z
  • DP4 R0.x, R1, R2 -
  • 4-component dot product

19
MUL instruction
  • MUL R1, R0, R2 (component-wise mult.)
  • R1.x R0.x R2.x
  • R1.y R0.y R2.y
  • R1.z R0.z R2.z
  • R1.w R0.w R2.w

20
MAD instruction
  • MAD R1, R2, R3, R4
  • R1 R2 R3 R4
  • component wise multiplication
  • Example
  • MAD R1, R0.yzxw, R2.zxyw, -R1
  • What does it do?

21
Cross Product Coding Example
Cross product R2 R0 x R1 MUL R2, R0.zxyw,
R1.yzxw MAD R2, R0.yzxw, R1.zxyw, -R2
22
Lighting instruction
  • LIT R1, R0 (Phong light model)
  • Input R0 (diffuse, specular, ??, shiness)
  • Output R1 (1, diffuse, specularshininess, 1)
  • Usually followed by
  • DP3 oCOL0, C21, R1 (assuming using
    c21)
  • where Cxx (ka, kd, ks, ??)
Write a Comment
User Comments (0)
About PowerShow.com