CSE 564: Visualization. GPU Programming (First Steps) GPU Generations. Klaus Mueller. Computer Science Department Stony Brook University



Similar documents
Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

Computer Graphics Hardware An Overview

Introduction to Computer Graphics

Introduction to GPGPU. Tiziano Diamanti

A Crash Course on Programmable Graphics Hardware

Writing Applications for the GPU Using the RapidMind Development Platform

Developer Tools. Tim Purcell NVIDIA

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

L20: GPU Architecture and Models

QCD as a Video Game?

OpenGL Shading Language Course. Chapter 5 Appendix. By Jacobo Rodriguez Villar jacobo.rodriguez@typhoonlabs.com

How To Write A Cg Toolkit Program

The Evolution of Computer Graphics. SVP, Content & Technology, NVIDIA

Programmable Graphics Hardware

GPGPU Computing. Yong Cao

GPU(Graphics Processing Unit) with a Focus on Nvidia GeForce 6 Series. By: Binesh Tuladhar Clay Smith

Computer Graphics CS 543 Lecture 12 (Part 1) Curves. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Vertex and fragment programs

Computer Graphics. Anders Hast

Introduction GPU Hardware GPU Computing Today GPU Computing Example Outlook Summary. GPU Computing. Numerical Simulation - from Models to Software

GPUs Under the Hood. Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of Technology

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

How To Teach Computer Graphics

Lecture Notes, CEng 477

OpenGL Performance Tuning

Computer Graphics on Mobile Devices VL SS ECTS

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

Graphics Cards and Graphics Processing Units. Ben Johnstone Russ Martin November 15, 2011

Optimizing AAA Games for Mobile Platforms

Real-Time Realistic Rendering. Michael Doggett Docent Department of Computer Science Lund university

GPU Shading and Rendering: Introduction & Graphics Hardware

Performance Optimization and Debug Tools for mobile games with PlayCanvas

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Learning Modern 3D Graphics Programming. Jason L. McKesson

The Future Of Animation Is Games

Computer Applications in Textile Engineering. Computer Applications in Textile Engineering

CS418 GLSL Shader Programming Tutorial (I) Shader Introduction. Presented by : Wei-Wen Feng 3/12/2008

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Web Based 3D Visualization for COMSOL Multiphysics

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

INTRODUCTION TO RENDERING TECHNIQUES

NVIDIA workstation 3D graphics card upgrade options deliver productivity improvements and superior image quality

Overview Motivation and applications Challenges. Dynamic Volume Computation and Visualization on the GPU. GPU feature requests Conclusions

NVFX : A NEW SCENE AND MATERIAL EFFECT FRAMEWORK FOR OPENGL AND DIRECTX. TRISTAN LORACH Senior Devtech Engineer SIGGRAPH 2013

3D Computer Games History and Technology

Game Development in Android Disgruntled Rats LLC. Sean Godinez Brian Morgan Michael Boldischar

Radeon GPU Architecture and the Radeon 4800 series. Michael Doggett Graphics Architecture Group June 27, 2008

OpenGL Insights. Edited by. Patrick Cozzi and Christophe Riccio

DATA VISUALIZATION OF THE GRAPHICS PIPELINE: TRACKING STATE WITH THE STATEVIEWER

Color correction in 3D environments Nicholas Blackhawk

BRINGING UNREAL ENGINE 4 TO OPENGL Nick Penwarden Epic Games Mathias Schott, Evan Hart NVIDIA

Data Visualization Using Hardware Accelerated Spline Interpolation

Radeon HD 2900 and Geometry Generation. Michael Doggett

Visualizing Data: Scalable Interactivity

AMD GPU Architecture. OpenCL Tutorial, PPAM Dominik Behr September 13th, 2009

GPU Architecture. Michael Doggett ATI

Introduction to Computer Graphics

Optimization for DirectX9 Graphics. Ashu Rege

GPU Profiling with AMD CodeXL

Recent Advances and Future Trends in Graphics Hardware. Michael Doggett Architect November 23, 2005

Optimizing Unity Games for Mobile Platforms. Angelo Theodorou Software Engineer Unite 2013, 28 th -30 th August

Parallel Web Programming

Graphics and Computing GPUs

Programming 3D Applications with HTML5 and WebGL

Introduction to GPU Programming Languages

General Purpose Computation on Graphics Processors (GPGPU) Mike Houston, Stanford University

Realtime 3D Computer Graphics Virtual Reality

NVPRO-PIPELINE A RESEARCH RENDERING PIPELINE MARKUS TAVENRATH MATAVENRATH@NVIDIA.COM SENIOR DEVELOPER TECHNOLOGY ENGINEER, NVIDIA

Instructor. Goals. Image Synthesis Examples. Applications. Computer Graphics. Why Study 3D Computer Graphics?

How To Understand The Power Of Unity 3D (Pro) And The Power Behind It (Pro/Pro)

Accelerating Intensity Layer Based Pencil Filter Algorithm using CUDA

LLVM for OpenGL and other stuff. Chris Lattner Apple Computer

Computer Graphics. Introduction. Computer graphics. What is computer graphics? Yung-Yu Chuang

ANDROID DEVELOPER TOOLS TRAINING GTC Sébastien Dominé, NVIDIA

Chapter 2 - Graphics Programming with JOGL

Windows Phone 7 Game Development using XNA

3D graphic acceleration history and architecture

CS 4204 Computer Graphics

Using Photorealistic RenderMan for High-Quality Direct Volume Rendering

The OpenGL R Graphics System: A Specification (Version 3.3 (Core Profile) - March 11, 2010)

CMSC 427 Computer Graphics Programming Assignment 1: Introduction to OpenGL and C++ Due Date: 11:59 PM, Sept. 15, 2015

OpenGL & Delphi. Max Kleiner. 1/22

Institution : Majmaah University. Academic Department : College of Science at AzZulfi. Programme : Computer Science and Information Course :

3D Modeling and Simulation using Image Stitching

COMP175: Computer Graphics. Lecture 1 Introduction and Display Technologies

Bachelor of Games and Virtual Worlds (Programming) Subject and Course Summaries

How To Make A Texture Map Work Better On A Computer Graphics Card (Or Mac)

Modern Graphics Engine Design. Sim Dietrich NVIDIA Corporation

Transcription:

GPU Generations CSE 564: Visualization GPU Programming (First Steps) Klaus Mueller Computer Science Department Stony Brook University For the labs, 4th generation is desirable Graphics Hardware Pipeline Vertex Stage Vertex values: position, color, texture coordinate(s), normal vector Operations (in a vertex program): perform a sequence of math ops on each vertex transform position into screen position for rasterizer generate texture coordinates for texturing perform vertex lighting to determine its color

Primitive Assembly and Rasterizer Primitive Assembly and Rasterizer Operations: assemble vertices into geometric primitives (triangles, lines, points) clipping to the view frustrum and other clip planes eliminate backward-facing polygons (culling) rasterize geometric primitives into fragments Rasterization: yields a set pixel locations and fragments What is a fragment? potential pixel (still subject to fragment kill) values: color, depth, location, texture coordinate sets Number of vertices and fragments are unrelated! Fragment Stage Raster Operations Final sequence of per-fragment operations before updating the framebuffer fragment may be discarded here as well Operations (fragment program): interpolation, texturing, and coloring math operations Output: final color (RGBA), depth output is either 1 or 0 fragments (may be discarded)

Graphics Pipeline: Summary Cg Vertices and fragments are vectors (up to dimension 4) Vertex and fragment stage are programmable Cg available to overcome need for assembler programming Developed by Nvidia Cg Can work with OpenGL as well as DirectX CG compiler produces OpenGL or DirectX code e.g., OpenGL s ARB_fragment_program language OpenGL or DirectX drivers perform final translation into hardware-executable code core CG runtime library (CG prefix) cggl and cgd3d libraries Simple Vertex Program to rasterizer semantics Semantics connect Cg program with graphics pipeline here: POSITION and COLOR float4, float2, float4x4, etc, are packed arrays operations are most efficient

Uniform vs. Varying Parameters varying Varying: values vary per vertex or fragment interfaced via semantics Uniform: remain constant interfaced via handles uniform Compilation To interface Cg programs with application: compile the program with appropriate profile - dependent on underlying hardware range of profiles will grow with GPU advances - OpenGL: arbvp1 (basic), vp20, vp30, vp40 (advanced Nvidia) Link the program to the application program Can perform compilation at compile time (static) runtime (dynamic) Cg Runtime Can take advantage of latest profiles optimization of existing profiles No dependency issues register names, register allocations In the following, use OpenGL to illustrate DirectX similar methods Preparing a Cg Program First, create a context: context = cgcreatecontext() Compile a program by adding it to the context: program = cgcreateprogram(context, programstring, profile, name, args) Loading a program (pass to the 3D API): cgglloadprogram(program) More detailed information available when you download CG from the Nvidia developer website: http://developer.nvidia.com Cg toolkit 2.0 now available (including Cg compiler)

Running a Cg Program Running a Cg Program Executing the profile: cgenableprofile(cg_profile_arbvp1) Bind the program: cgglbindprogram(program) After binding, the program will execute in subsequent drawing calls for every vertex (for vertex programs) for every fragment (for fragment programs) these programs are often called shaders Only one vertex / fragment program can be bound at a time the same program will execute unless another program is bound Disable a profile by: cggldisableprofile(cg_profile_arbvp1) Release resources: cgdestroyprogram(program) cgdestroycontext(context) the latter destroys all programs as well Error Handling There are core CG routines that retrieve global error variables: error = cggeterror() cggeterrorstring(error) cgset ErrorCallback(MyErrorCallback) Passing Parameters into CG Programs Assume these shader variables: float4 position : POSITION float4 color : COLOR0 Get the handle for color by: color = cggetnamedparameter(program, "IN.color") Can set the value for color by: cgglsetparameter4f(color, 0.5f, 1.0f, 0.5f, 1.0f) Uniform variables are set infrequently: example: modelviewmatrix

Passing Parameters into CG Programs Example 1 Vertex program Set other variables via OpenGL semantics: glvertex, glcolor, gltexcoord, glnormal, Example: rendering a triangle with OpenGL: glbegin(gl_triangles); glvertex( 0.8, 0.8); glvertex(-0.8, 0.8); glvertex( 0.0, -0.8); glend(); glvertex affects POSITION semantics and updates/sets related parameter in vertex shader OUT parameter values are passed to fragment shader Example 1 Example 2 Fragment program, following example 1 vertex program Result, assumimg: a fragment shader that just passes values through OpenGl program glbegin(gl_triangles); glvertex( 0.8, 0.8); glcolor(dark); glvertex(-0.8, 0.8); glcolor(dark); glvertex( 0.0, -0.8); glcolor(light); glend(); Sampler2D is a texture object other types exist: sampler3d, samplercube, etc

Example 2 Example 2 Tex2D(decal, texcoord) performs a texture-lookup sampling, filtering, and interpolation depends on texture type and texture parameters advanced fragment profiles allow sampling using texture coordinate sets from other texture units (dependent textures) Result Math Support A rich set of math operators and library functions +-/*, sin, cos, floor, etc. no bit-wise operators yet, but operators reserved Latest hardware full floating point on framebuffer operations half-floats are also available Function overloading frequent for example, abs() function accepts float4, float2 Syntax IN keyword call by value parameter passing by value OUT keyword indicates when the program returns

Example 3 Example 3 2D Twisting (vertex program) Result finer meshes give better results Example 4 Double Vision: vertex program Example 4 Double Vision: fragment program #1 advanced fragment profiles samples the same texture (named decal) twice lerp(a, b, weight) result = (1-weight) a + weight b OUT is defined via semantics in the prototype optional

Example 4 Example 4 Result Double Vision: fragment program #2 basic fragment profiles samples two different textures (decal0 and decal1) textures must be bound to two texture units in advance Further Resources Book The CG Tutorial: The Definite Guide to Programmable Real-Time Graphics by R. Fernando and M. Kilgard, Addison Wesley, 2003 Web developer.nvidia.com/cg www.cgshaders.org many other resources on the web Try hacking some existing code to get what you want Note: DirectX and OpenGL code is relatively easy to convert Other non-cg resources: GLSL (GL Shading Language): generic Cg from the GL consortium HLSL: Microsoft s Cg (very similar to CG), bound to DirectX, Direct3D (does not run with GL) Brook (Stanford U), SH (U Waterloo), CUDA (Nvidia), CTM (AMD/ATI): interfaces for general purpose computing on GPUs Some simple tasks posted on the class website First Programming Project This first project s goals are: set up your machine with the Cg programming environment or locate the environment on the lab machine get used to Cg itself Due date within a week