Introduction to Programmable Hardware

Slides:



Advertisements
Similar presentations
Fragment level programmability in OpenGL Evan Hart
Advertisements

DirectX 8 and GeForce3 Christian Schär & Sacha Saxer.
COMPUTER GRAPHICS CS 482 – FALL 2014 NOVEMBER 10, 2014 GRAPHICS HARDWARE GRAPHICS PROCESSING UNITS PARALLELISM.
Michael I. Gold NVIDIA Corporation
Frame Buffer Postprocessing Effects in DOUBLE-S.T.E.A.L (Wreckless)
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
CS-378: Game Technology Lecture #9: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
Interactive High-Quality Volume Rendering on Flexible Consumer Graphics Hardware Klaus Engel, Martin Kraus, Thomas Ertl Visualization and Interactive Systems.
9/25/2001CS 638, Fall 2001 Today Shadow Volume Algorithms Vertex and Pixel Shaders.
The Programmable Graphics Hardware Pipeline Doug James Asst. Professor CS & Robotics.
Shading Languages GeForce3, DirectX 8 Michael Oswald.
A Crash Course on Programmable Graphics Hardware Li-Yi Wei 2005 at Tsinghua University, Beijing.
Modern Graphics Hardware 2002 Vertex Programs Joe Michael Kniss.
Status – Week 277 Victor Moya.
GPU Simulator Victor Moya. Summary Rendering pipeline for 3D graphics. Rendering pipeline for 3D graphics. Graphic Processors. Graphic Processors. GPU.
Status – Week 276 Victor Moya. Hardware Pipeline Command Processor. Command Processor. Vertex Shader. Vertex Shader. Rasterization. Rasterization. Pixel.
ARB Fragment Program in GPULib. Summary Fragment program arquitecture New instructions.  Emulating instructions not supported directly New Required GL.
Status – Week 279 Victor Moya. Rasterization Setup triangles (calculate slope values). Setup triangles (calculate slope values). Fill triangle: Interpolate.
Status – Week 283 Victor Moya. 3D Graphics Pipeline Akeley & Hanrahan course. Akeley & Hanrahan course. Fixed vs Programmable. Fixed vs Programmable.
Status – Week 281 Victor Moya. Objectives Research in future GPUs for 3D graphics. Research in future GPUs for 3D graphics. Simulate current and future.
Vertex & Pixel Shaders CPS124 – Computer Graphics Ferdinand Schober.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
Under the Hood: 3D Pipeline. Motherboard & Chipset PCI Express x16.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
Computer Graphics 3 Lecture 4: GPU Programming Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
What is ? Open Graphics Library A cross-language, multi-platform API for rendering 2D and 3D computer graphics. The API is used to interact with a Graphics.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Using Vertex Shader in DirectX 8.1 강 신 진
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Cg Programming Mapping Computational Concepts to GPUs.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Blending, Modern Hardware.
The Graphics Rendering Pipeline 3D SCENE Collection of 3D primitives IMAGE Array of pixels Primitives: Basic geometric structures (points, lines, triangles,
Computer graphics & visualization The programmable (D3D 10) Pipeline.
1 Dr. Scott Schaefer Programmable Shaders. 2/30 Graphics Cards Performance Nvidia Geforce 6800 GTX 1  6.4 billion pixels/sec Nvidia Geforce 7900 GTX.
CSE 690: GPGPU Lecture 6: Cg Tutorial Klaus Mueller Computer Science, Stony Brook University.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
VIS Group, University of Stuttgart Tutorial T4: Programmable Graphics Hardware for Interactive Visualization Programmable Graphics Hardware (Martin Kraus)
CS662 Computer Graphics Game Technologies Jim X. Chen, Ph.D. Computer Science Department George Mason University.
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
A User-Programmable Vertex Engine Erik Lindholm Mark Kilgard Henry Moreton NVIDIA Corporation Presented by Han-Wei Shen.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Lab: Vertex Shading Chris Wynn Ken Hurley. Objective Hands-On vertex shader programming Start with simple programs … Part 1: Textured-Lit Teapot.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
David Luebke 1 1/25/2016 Programmable Graphics Hardware.
09/25/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Shadows Stage 2 outline.
Ray Tracing using Programmable Graphics Hardware
Mesh Skinning Sébastien Dominé. Agenda Introduction to Mesh Skinning 2 matrix skinning 4 matrix skinning with lighting Complex skinning for character.
Pixel Shader  Based on nVIDIA’s GF3/4 architecture  Texture shader + register combiner texture unit 0texture program texture unit 1texture program texture.
High-Quality Pre-Integrated Volume Rendering Using Hardware Accelerated Pixel Shading Klaus Engel, Martin Kraus, Thomas Ertl Visualization and Interactive.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
Programmable Shaders Dr. Scott Schaefer.
Programmable Pipelines
The Graphic PipeLine
A Crash Course on Programmable Graphics Hardware
CS427 Multicore Architecture and Parallel Computing
Graphics Processing Unit
Chapter 6 GPU, Shaders, and Shading Languages
The Graphics Rendering Pipeline
Day 05 Shader Basics.
Graphics Processing Unit
Where does the Vertex Engine fit?
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
CIS 6930: Chip Multiprocessor: GPU Architecture and Programming
Presentation transcript:

Introduction to Programmable Hardware

Traditional Graphics Pipeline transform & lighting (per vertex operations) setup rasterizer (per primitive operation) texture blending (per fragment operation) frame-buffer anti-aliasing

Programmable features Vertex Programming Pixel Shader Texture shader Register combiner Based on nVIDIA architecture

Gives the programmer total control of vertex processing. Vertex Program (cont’d) Vertex Programming offers programmable T&L unit User-defined Vertex Processing transform & lighting setup rasterizer texture blending Gives the programmer total control of vertex processing. frame-buffer anti-aliasing

Vertex Program (cont’d) transform & lighting setup rasterizer texture blending frame-buffer anti-aliasing

Vertex Program (cont’d) Assembly language interface to T&L unit GPU instruction set to perform all vertex math Reads an untransformed, unlit vertex Creates a transformed vertex Optionally creates Lights a vertex Creates texture coordinates Creates fog coordinates Creates point sizes

Create Vertex Program Programs (assembly) are defined inline as character strings static const GLubyte vpgm[] = “\!!VP1. 0\ DP4 o[HPOS].x, c[0], v[0]; \ DP4 o[HPOS].y, c[1], v[0]; \ DP4 o[HPOS].z, c[2], v[0]; \ DP4 o[HPOS].w, c[3], v[0]; \ MOV o[COL0],v[3]; \ END";

Programming Model All quad floats Vertex Source Program Constants … V[15] Vertex Source Program Constants c[0] … c[96] 16x4 registers O[HPOS] O[COL0] O[COL1] O[FOGP] O[PSIZ] O[TEX0] … O[TEX7] Vertex Program 96x4 registers 128 instructions Temporary Registers R0 … R11 12x4 registers Vertex Output 15x4 registers All quad floats

Instruction Set: The ops 17 instructions total MOV, MUL, ADD, MAD, DST DP3, DP4 MIN, MAX, SLT, SGE RCP, RSQ, LOG, EXP, LIT ARL

Pixel Shader transform & lighting setup rasterizer User-defined per frame-buffer anti-aliasing texture blending setup rasterizer transform & lighting User-defined per pixel shading

Texture Mapping/Blending Traditional OpenGL texture mapping/blending Vertex colors Gouraud Shading Fragment color Texture Coordinate Texture Unit Blend colors Fragment color output

Multitexturing An optional extension of OpenGL 1.2 fragment color input texture unit 0 blend colors texture unit 0 blend colors texture unit 0 blend colors texture unit 0 blend colors fragment color output

Texture Compositing OpenGL 1.2 Texture Fetching Texture Environment Fragment Color Texture Environment Texture Fetching Texture Environment 1 Tex0 Tex1 Specular Color Sum Specular Color Fog Application Fog Color/Factor

Compositing Operator Choice of 5 set functions for RGB and Alpha: Ct: texture color; At: texture alpha Cf: incoming fragment color; Af: incoming fragment alpha Cc: color assigned to GL_TEXTURE_ENV_COLOR Post-environment specular color addition and fog application Function RGB Alpha Replace Ct At Modulate Cf Ct Af At Decal Cf (1 – At) + Ct At Af Blend Cf (1 – Ct) + Cc Ct Add Cf + Ct

Pixel Shader (cont’d) Based on nVIDIA’s GF3/4 architecture Texture shader 4 texture units 23 different texture shader operations Conventional (1D, 2D, 3D, texture rectangle, cube map) Special case (none, pass through, cull fragment) Dependent texture fetches (result of one texture lookup affects texture coords for subsequent unit) Dependent textures fetches with dot product (and optional reflection) calculations Register combiners 8 stages (general combiners) on GeForce3/4 Per-stage constants

Pixel Shader Based on nVIDIA’s GF3/4 architecture Texture shader + register combiner texture shader fragment color input texture unit 0 texture program texture unit 1 texture program texture unit 2 texture program texture unit 3 texture program register combiner fragment color output

Bound Texture Target/Format Texture Shader Texture program example: conventional 2D texture Tex # Texture Coords (S,T,R,Q) Shader Operations Texture Fetch Bound Texture Target/Format Output Color 2D Any Format Texture 2D Si Ti i (Si,Ti,Ri,Qi) ( , ) (R,G,B,A) Qi Qi

Texture Shader (cont’d) Texture program example: pass through Shader Operations Texture Fetch Output Color (Si,Ti,Ri,Qi) None Bound Texture Target/Format (R,G,B,A) R = Clamp0to1(Si) G = Clamp0to1(Ti) B = Clamp0to1(Ri) A = Clamp0to1(Qi)

Texture Shader (cont’d) Texture program example: dependent texture Tex # Texture Coords (S,T,R,Q) Shader Operations Texture Fetch App specific Texture specific Any type Unsigned RGB[A] R0G0B0A0 1 (A0,R0) Bound Texture Target/Format R1G1B1A1 Ignored None 2D RGBA

Register Combiner GeForce 2 (only 2 general combiner stages) 4 RGB Inputs Fragment Color 4 Alpha Inputs General Combiner 3 RGB Outputs Specular Color 3 Alpha Outputs Fog Color/Factor 4 RGB Inputs 4 Alpha Inputs Register Set General Combiner 1 Texture 0 Texture Fetching 3 RGB Outputs 3 Alpha Outputs Texture 1 Spare 0 Specular Color Final Combiner 6 RGB Inputs 1 Alpha Input

Register Combiner (cont’d) Register-based programming All textures and colors available for each and every texture blending stage 8 Stages of blending in hardware, plus specular and fog Note that GeForce3 has 8 combiners, and 4 textures. Signed color arithmetic

Diagram of a General Combiner Input RGB, Alpha Registers Input Mappings RGB Function RGB Scale/Bias Next Combiner’s RGB Registers A A op1 B B RGB Portion C op2 D C AB op3 CD D Input Alpha, Blue Registers Input Mappings Alpha Function Alpha Scale/Bias Next Combiner’s Alpha Registers A AB Alpha Portion B CD C AB op4 CD D

General Combiner Input Registers Input RGB, Alpha Registers Input Mappings RGB Function RGB Scale/Bias Next Combiner’s RGB Registers A A op1 B B RGB Portion C op2 D C AB op3 CD D Input Alpha, Blue Registers Input Mappings Alpha Function Alpha Scale/Bias Next Combiner’s Alpha Registers A AB Alpha Portion B CD C AB op4 CD D

The Register Set Primary (diffuse) color initialized to RGBA of fragment’s primary color Secondary (specular) color initialized to RGB of fragment’s secondary/specular color alpha not initialized Texture 0 and Texture 1 colors initialized to fragment’s filtered RGBA texel from numbered texture unit not initialized if numbered texture unit is disabled or non-existent Spare 0 and Spare 1 Alpha of Spare 0 is initialized to alpha of Texture 0 color (if enabled) RGB of Spare 0 and all of Spare 1 is not initialized Fog RGB is current fog color alpha is fragment’s fog factor (only available in final combiner) read-only Constant color 0 and Constant color 1 initialized to user-defined RGBA value Zero constant, read-only value of zero

General Combiner Input Mappings Input RGB, Alpha Registers Input Mappings RGB Function RGB Scale/Bias Next Combiner’s RGB Registers A A op1 B B RGB Portion C op2 D C AB op3 CD D Input Alpha, Blue Registers Input Mappings Alpha Function Alpha Scale/Bias Next Combiner’s Alpha Registers A AB Alpha Portion B CD C AB op4 CD D

General Combiner Input Mappings Signed Identity f(x) = x [-1, 1]  [-1, 1] Unsigned Identity f(x) = max(0, x) [0, 1]  [0, 1] Expand Normal f(x) = 2 * max(0, x) - 1 [0, 1]  [-1, 1] Half Bias Normal f(x) = max(0, x) – ½ [0, 1]  [-½, ½] Signed Negate f(x) = -x [-1, 1]  [1, -1] Unsigned Invert f(x) = 1-min(max(0,x),1) [0, 1]  [1, 0] Expand Negate f(x) = -2 * max(0, x) + 1 [0, 1]  [1, -1] Half Bias Negate f(x) = -max(0, x) + ½ [0, 1]  [½, -½]

General Combiner RGB Function Input RGB, Alpha Registers Input Mappings RGB Function RGB Scale/Bias Next Combiner’s RGB Registers A A op1 B B RGB Portion C op2 D C AB op3 CD D Input Alpha, Blue Registers Input Mappings Alpha Function Alpha Scale/Bias Next Combiner’s Alpha Registers A AB Alpha Portion B CD C AB op4 CD D

General Combiner RGB Functions Dot / Dot / Discard Dot / Mult / Discard Mult / Dot / Discard A A A A • B A • B AB B B B C • D CD C • D C C C D D D Mult / Mult / Mux Mult / Mult / Sum A A AB AB B B CD CD C C mux(AB, CD) AB + CD D D mux(AB, CD) = (Spare0[Alpha]  ½) ? AB : CD Dot products on RGB registers: A • B = (A[red] * B[red] + A[green] * B[green] + A[blue] * B[blue], A[red] * B[red] + A[green] * B[green] + A[blue] * B[blue], A[red] * B[red] + A[green] * B[green] + A[blue] * B[blue]) Multiplication on RGB registers: AB = (A[red] * B[red], A[green] * B[green], A[blue] * B[blue])

Diagram of the Final Combiner (OpenGL only) Input RGB, Alpha Registers Available RGB Inputs Input Mappings RGB Function Input Mappings A Multiplier E EF B F RGB Portion AB + (1-A)C + D RGB Out Color Sum Unit Clamp to [0, 1] C Spare0 Sum 2nd-ary Color D Input Alpha, Blue Registers Input Mapping Alpha Portion Alpha Out