DOC PREVIEW
GT ECE 4893 - Lecture 12: XNA and Programmable Shaders
School name Georgia Tech
Pages 14

This preview shows page 1-2-3-4-5 out of 14 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

10/5/08 1 Lecture 12: XNA and Programmable Shaders Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Institute of Technology DirectX and GPU (Nvidia-centric) History DirectX 6!Multitexturing!Riva TNT!DirectX 8!SM 1.x!GeForce3!Cg!DirectX 9!SM 2.0!GeForceFX!DirectX 9.0c!SM 3.0!GeForce 6!DirectX 5!Riva 128!1998! 1999! 2000! 2001! 2002! 2003! 2004!DirectX 7!T&L !GeForce 256!(NV10) (NV4) NVidia’s response to Voodoo2 3dfx demise 1996!3dfx’s first Voodoo chip (NV20) (NV30) (NV40) 2006!DirectX 10!SM 4.0!GeForce 8!(G80) 686 million Transistors 1.5GHz Adapted from David Kirk’s slide DirectX 2!2008!GeForce 9!GTX200 1.4 billion Transistors GT 200!Why Programmable Shaders • Hardwired pipeline – Produces limited effects – Effects look the same – Gamers want unique look-n-feel – Multi-texturing somewhat alleviates this, but not enough – Less interoperable, less portable • Programmable Shaders – Vertex Shader – Pixel or Fragment Shader – Starting from DX 8.0 (assembly) – DX 9.0 added HLSL (High Level Shading Language) – HLSL (MS) is compatible with Cg (Nvidia) Evolution of Graphics Processing Units • Pre-GPU – Video controller – Dumb frame buffer • First generation GPU – PCI bus – Rasterization done on GPU – ATI Rage, Nvidia TNT2, 3dfx Voodoo3 (‘96) • Second generation GPU – AGP – Include T&L into GPU – Nvidia GeForce 256, ATI Radeon 7500, S3 Savage3D (’98) • Third generation GPU – Programmable vertex shader – Nvidia GeForce3, ATI Radeon 8500, Microsoft Xbox (’01) • Fourth generation GPU – Both programmability in vertex and fragment shaders – Nvidia GeForce FX, ATI Radeon 9700 (’02) • Current generation GPU – Include geometry shader (SM 4.0 and DX10) – Nvidia G80 and up10/5/08 2 Programmable Graphics Pipeline Source: Cg tutorial 3D Apps 3D API: Direct3D GPU Frontend Primitive Assembly Rasterization & Interpolation Raster Operations Frame Buffer Programmable Vertex Shader Programmable Fragment Shader Transformed vertices Transformed Fragments API commands GPU cmd & data stream Vtx index Assembled polygons Pixel location Pixel updates NVidia GeForce FX Fixed Function Pipeline Graphics Programmable Pipeline Vertices Vertex Shader HW T&L Culling Clipping Rasterization Blend Mask FixFunc Pixel Pixel Shader Input Assembler Geometry Shader Rasterization Output Merger Vertex Shader Pixel Shader DirectX 10.0 Pipeline, Fully Programmable DirectX 8.0 Pipeline Choice between programmable and fixed function pipeline (mutually exclusive, parallel pipelines) XNA Rendering Pipeline • Vertex shader outputs transformed vertex position, texture coordinates, color, etc. – Solid deforming, skeletal animation, particle motion, etc. • Rasterization interpolates and determines what pixels to draw • Pixel shader outputs pixel color, depth (optional) – Per-pixel lighting, procedural texture generation, postprocessing effects, brightness, contrast, blur, etc. Vertex Data (Model Space) Vertex Processing Rasterization Pixel Processing Output Merger Other Memory Resource (Texture, Constants, etc) Adapted from XNA 2.0 Game Programming Book Final image : Programmable : Fixed operations : Data supply Shader Languages • HLSL/Cg most common – Both are compatible – No assembly shaders allowed in DX 10.0. • Other options: – GLSL – Legacy DirectX shaders in assembly – Sh – OpenVidia (U of Toronto)10/5/08 3 Basic Shader Mechanics • Data types: – Typically floats, and vectors/matrices of floats – Fixed size arrays – Three main types: • Per-instance data, e.g., per-vertex position • Per-pixel interpolated data, e.g., texture coordinates • Per-batch data, e.g., light position – Data are tightly bound to the GPU – Flow control is very simple: • No recursion • Fixed size loops for v_2_0 or earlier • Simple if-then-else statements allowed in the latest APIs • Texkill (asm) or clip (HLSL) or discard (GLSL) or allows you to abort a write to a pixel (form of flow control) Vertex Shader • Transform to clip-space (i.e., screen space) • Inputs: – Common inputs: • Vertex position (x, y, z, w) • Texture coordinate • Constant inputs • Can also have fog, color as input, but usually leaves them untouched for pixel shader – Output to Pixel (fragment) shader • Vertex shader is executed once per vertex, could be less expensive than pixel shader oD1 Vertex Shader (3.0) Vertex Shader v15 v0 v1 v2 16 Vertex data registers Vertex stream Cn C0 C1 C2 Constant float registers (at least 256) 16 Constant Integer Registers r31 r0 r1 r2 32 Temporary registers Each register is a 4-component vector register except aL aL Loop Register a0 Address Register oPos oTn texture position fog oFog oD0 Diff. color Spec. color oPts Output Pt size 12 output registers Pixel (or Fragment) Shader • Determine each fragment’s color – custom (sophisticated) pixel operations – texture sampling • Inputs – Interpolated output from vertex shader – Typically vertex position, vertex normals, texture coordinates, etc. – These registers could be reused for other purposes (thus called GPGPU) • Output – Color (including alpha) – Depth value (optional) • Executed once per pixel so is executed a lot more times than vertex shader typically – It is advantageous to compute stuff on a per-vertex basis to improve performance10/5/08 4 Pixel Shader (3.0) Pixel Shader Color (diff/spec) and texture coord. registers Pixel stream Cn C0 C1 Constant registers (16 INT, 224 Float) r31 r0 r1 Temporary registers oC0 oDepth Depth color s15 s0 s1 Sampler Registers (Up to 16 texture surfaces can be read in a single pass) v9 v0 v1 Use of the Vertex Shader • Transform vertices to clip-space • Pass normal, texture coordinates to PS • Transform vectors to other spaces (e.g., texture space) • Calculate per-vertex lighting (e.g., Gouraud shading) • Distort geometry (waves, fish-eye camera) Adapted from Mart Slot’s presentation Use of the Pixel Shader • Texturing objects • Per-pixel lighting (e.g., Phong shading) • Normal mapping (each pixel has its own normal) • Shadows (determine whether a pixel is shadowed or not)


View Full Document

GT ECE 4893 - Lecture 12: XNA and Programmable Shaders

Documents in this Course
Load more
Download Lecture 12: XNA and Programmable Shaders
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 12: XNA and Programmable Shaders and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 12: XNA and Programmable Shaders 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?