Professional Documents
Culture Documents
Graphics Card Connection Bus PCI Express (PCIe) General Architecture of GPU
• Released in 2002 • Multiple processors
• The graphics card is PICe x
16 bus
CPU • PCI bus is the oldest – Compatible with old PCI bus – Stream Processor , Parallel computing
connected to north one. • Multiple ALUs (cores) in each
Main processor
bridge via a bus. monitor
Graphics
North
memory • AGP is faster. • Lower power consumption – Parallel computing, multiple threads
bridge
card • Serial ports (multiple ports) – Processor clusters
–單晶片系統不採用南 • PCI express is the – Dual direction • Hierarchical memory structure
橋、北橋架構,for –
examples, AMD,Intel
fastest bus. Main memory in the mother board
PCI bus • Newest version: PCIe x 16 – Shared memory in the graphic card
Other GPU Functionalities Famous GPU Manufacturers Some New Applications Graphics Memory
• A GPU may contain multiple • Nvidia • Artificial intelligence • New features • AKA video memory
ALUs for shading purpose. • ARM – Pattern recognition – Thousands of thread – Several Giga-byte DDR (Dual Data Rate) memory
• It can process multiple • Intel – Deep learning processors (grouped in • For keeping information
vertices in parallel. • AMD (ATI) – Video stream processing clusters)
– Geometrical data: vertex, normal, connectivity, …
• It can render several pixels at • Characteristics of GPU – Multiple ports
• Super-computing – May lacking of display (for
– Textures (very important)
the same time. – Graphics computing – Images
• It can do other general – Lower power consumption • Self-driving cars super-computing)
– Higher computing power – Shading programs (written by programmers)
purpose computing. – Limited functionalities • Cloud computing – Other temporary data: scalars, vectors, matrices,…
– CUDA & OpenCL, for – Lower precision (numerically) • General-purpose – System on chip architecture
examples – Massively parallel – AI computing • On-board or in the graphic card
computing on graphics • Large register file (several megabytes), fast accessing speed.
• Floating and integer arithmetic – System on Chip (SoC) – Innovative
–
processing units
operations are supported More applications, smart-
(GPGPU), … programming/computing • Hierarchical architecture/ controlled by memory controllers
phones, game kits, AR, VR environments
head-mount display, …
Graphic Programming Environment unctionalities of the Components (1/ ) Functionalities of the Components (2/2)
Deep Learning & GPU
• Programs of graphics : • Window manager (視窗管理)
Graphic software system
software system – To offer users an interactive user interface (environment)
• AI chip = GPU (advanced GPUs) Coordinators between OS and application programs – To create, move, iconfy & kill windows
– Operating System (OS) andler of graphical /O devices
Application Window Application – To create and manage window hierarchy
• Usage: and drivers/mid-ware
Program1 Manager Program2 Displaying buffer contents (swapping buffers), • Main window, sub-windows,…
– Display server Mouse/keyboard/joystick (optional) controlling – To manage window attributes
– Model training (learning) – Window manager • Background/ foreground colors
– Run-time pattern detection – Application programs Drawing primitives, ( , 、 、 單 ) • Text color, fonts, size, …
– Graphics libraries • Size, position, title, shape, …
– Run-time classification • Rendering subroutines
Display Server : – To handle I/O devices of window systems
• Graphical User Interface Users programs with Graphical User nterface ( GU ) • Mouse/keyboard/… (optional)
– 作為加速器… libraries • Menu system
(GUI) design tools
libraries Producing visual effects – Pop-up menu, menu bar, sliders,
• Multiple GPUs in a single board – Tool kits mage processing/displaying, rendering, CAGD, CAD, • Famous window systems:
• … images
– Many ALU in a single GPU (Nvidia A10, A40, …) animation, games, – X-window, MS Windows, Apples’ Mac OS Window
Graphical Programming Libraries OpenGL Libraries Usage of GLUT GU Design Using glut
Libraries forGU design: glut, glui, gtk, t, mGui Three libraries are included: General GU design method:
Main purpose is for design Create a (connection between the application
Libraries forrendering (drawing):OpenGL, glu, vtk, the original OpenGL library
Creating connection between application programs and the program and the window system)
extension of gl lib window system (window manager, display server) Define window attributes (title, position, foreground
We use to create user interface and to background color, fonts, )
render objects for GU design (major function) routines,
vent handling mechanism, /O device controlling, simple Define the display mode (color, depth, transparency )
ou are encouraged to learn shading languages, like glsl, volved from SG s GL library GU Create the window(s)
cg,
Please also learn some libraries for GU design, like Available in PC, Unix, Mac OSx and Linux Other functions: Geometric modelling, rendering, text display nitialize parameters and variables (viewing projection)
mGU , glui,
systems egister callback functions for events
Create a hierarchical pop up menu system
note this class is designed for learning fundamental computer graphics
knowledge All example codes are written by using OpenGL1
C like libraries nter the infinite loop (the arbiter)
Steps to Make a Simple GU with GLUT Steps (continued) Steps (continued) Steps (continued)
Step1: make a n with the window system Step define display mode Step 4 Create the window Step stablish a hierarchical menu system
(optional)
Possible display modes This procedure takes a string (window title) as input and Talk about this function later
GLUT G A, GLUT G return an integer as the window D
GLUT S NGL , GLUT DOU L
GLUT D PT , GLUT ALP A, GLUT ST NC L Step nter the infinite loop (of the arbiter)
GLUT ACCUM Step egister callback functions
Step : define geometrical parameters for the window Multiple modes can be combined by using bitwise O operator
The initial position //display event
//reshape event
The window size //keyboard event
Display vent More about vents eshape vents eshape vent Callback
Occurs when: egister the callback:
egister a display event handling routine: The display callback function usually triggers a window pops up, glut eshape unc(my reshape)
/ register the display event callback / the redrawing of the scene the window s size (shape) is changed
What to do ormat of this callback:
視窗 ,
re set the projection matrix (what is
ormat of the callback function this )
re draw the scene (triggers display
Carefully design this procedure event es )
Summary Overview of Menu System Menu utton vents Menu System Creation
in glut
Two major U mechanisms GLUT only provides popup menus Create a menu system with A menu
The arbiter (loop), events, callback functions We did it some Declare a handle (integer)
ierarchical menu system (see this topic later) Single and multi level menus When a menu button is int c menu
A menu contains several buttons ( ) pressed Color Create the handle:
Common events handled by glut ach button represents a functionality eturning the associate value of
Size
eyboard events Users select menu buttons to trigger functionalities the menu button c menu glutCreateMenu(color func)
Mouse events uttons generate input signals (events) umping to the designated Add menu entries (buttons):
Motion event callback function
utton events are handled by callback functions ile
glutAddMenu ntry( white , W T )
Display event One callback for one menu
utton event callbacks ordinary callbacks andling all buttons of this menu glutAddMenu ntry( red , D)
eshape event One callback for one menu Menu callback
Useful for creating user glutAddMenu ntry( green , G N)
Can callbacks be shared by menus es interface glutAddMenu ntry( blue , LU )
See the following slides for building a hierarchical menu system
One Level Menu (cont ) Callback of Menu utton Multi Level Menu Creation Multi level Menu Creation
Define an 1 level menu system (continued) Define the menu callback: one menu one callback
Create sub menus Create the top menu:
void color func(int value) top m glutCreateMenu(top menu func) / Create the top menu /
Associate the menu with a mouse key: switch(value) //handling individual menu buttons (entries) / create sub menus /
/ associate top menu with right but / case W T : color m glutCreateMenu(color func) nter submenus and entries (optional)
glutAttachMenu(GLUT G T UTTON) myColor 0 myColor 1 myColor 10 glutAddMenu ntry( white , W T )
break glutAddMenu ntry( red , D) glutAddSubMenu( colors , color m) / add color sub menu 1 /
case D: glutAddMenu ntry( green , G N) glutAddSubMenu( file , file m) / add file sub menu /
myColor 0 1 0 myColor 1 myColor 00
glutAddMenu ntry( blue , LU ) glutAddMenu ntry( exit , 1) //we can add entries into the top menu
break
: / Create another sub menu, file menu / glutAttachMenu(GLUT G T UTTON) / associate with right but /
default: file m glutCreateMenu(file func)
break glutAddMenu ntry( clear , M CL A )
Write the top menu callback by yourself
glutAddMenu ntry( uit , M U T)
String Display
The lowchart Character Display
endering a string on the window
Summary
Steps in multi level menu The flowchart Write texts by using glut instructions //the string ended with 0 Creating GU with glut
creation gl asterPos i( x, y) // location to start printing text
Programming style: event driven,
Declare handles of the top (x, y): position in the raster (window)
vents from hardware: keyboard, mouse, motion,
menu and the sub menus vents from window: reshape and display events,
glut itmapCharacter(font, c) //write a character
Create the sub menus one Callback: procedures to handle events and carry out
by one ont GLUT TMAP T M S OMAN 4, //initial position suitable computation,
c the character to write
Create the top menu Menu system: menu entries, basic menu, hierarchical
nter the sub menus menu, callback functions
buttons into the top menu Take home assignment:
Attach the menu system to Designing a GU and ealizing it
a mouse key Create an interactive D drawing panel
Data Types in OpenGL Digression, Other Color Models Define a Position ow to Draw an Object
OpenGL 1 x and x
SL: hue, saturation, light Specify the of a vertex
or portability, OpenGL defines some data Defining a position in the D, D or 4D space
Define its color and other attributes first
types S : hue, saturation, value ut, no geometrical entity (point) is specified Then draw the object:
Most used OpenGL data types: C rCb: Luminance (brightness) , Cr: saturation of OpenGL pipeline will create it //gl egin( ) gl nd() Use to define the object type the
nstructions ( ,不 )
, Cb: saturation of //human skin color mod el // D position
vertex coordinates of the object
types meaning abbreviations Lab: brightness (lightness) , (a /G), (b / ) // D position, integer type Object types include ,
// float p0 array The vertices are enclosed within gl egin() gl nd()
yellow gl asterPos i( x, y) // move to a location in the window
CM : cyan, magenta, yellow, black
The format
(Subtractive color system, for printing images) Drawn by the
gl library name , ertex instruction name , default shader
f float parameters
, and are the parameters
Digression: defining an object Draw Points and Lines Attributes of Point Line Draw a Polygon
asic components: vertices Draw points: Define A polygon is defined by using a se uence of vertices
gl egin(GL PO NTS) / Draw points / gl egin(GL POL GON)
Primitive Geometries
gl ertex f(x, height y, 0) //define the coordinates for(i 0 i side i )
Points vertices Size point size measured by pixels
gl ertex f(10, ) //define the coordinates (vertex i 0 , height vertex i 1 )
Line vertices gl nd() Why float Why not integer gl nd()
Triangle vertices Outside gl egin() gl nd() //otherwise no effect Another example
Draw lines: gl egin(GL POL GON)
Polygon a list of vertices
gl egin(GL L N S) / Draw a line / Define gl ertex f(0, 0)
(Convex polygons only) gl ertex f(pos x, height pos y) //define the coordinates gl ertex f(10, 10)
gl ertex f(x, height y) //define the coordinates gl ertex f(10, 0)
OpenGL vertex不 primitive, gl nd() Width , thickness pixels, 0 for anti aliasing gl nd()
Draw several lines Outside gl egin() gl nd() //define attributes before gl egin()
Draw Style Attributes uestions rame uffer /O ead from rame uffer
Draw style command: Other attribute The default center of the aforementioned uadric We can read portion contents of the frame ead the contents of a in the frame
glu uadricDrawStyle (sphere, object is (0, 0, 0), the origin
style) commands buffer buffer
This command defines the or example, color: Procedure
fill mode of the uadric ow can we draw a circle centered at the cursors Color buffers (front or back)
object position
xecute this command , G, , A channels,
before drawing the uadric
glColor f(r, g, b)
gl asterpos i(x, height y) //move to new origin Depth buffer,
objects
Options: height window height We can also write image data into these
GLU LL //default (x, y) cursor position buffers
GLU L N
ow can we draw a sphere at an arbitrary D position What is pack alignment
GLU PO NT specially color buffers
GLU S L OU TT Discussed in the geometrical transformation lectures See the next slide
Memory Alignment: Pack and Unpack Memory Alignment xamples Scope of uffer for eading uffer eading xample
ead GA values from the front buffer
Pack and unpack Alignment 4 The starting address of each We can read the contents of a rectangle in a buffer
//declare an G array
item is a multiple of 4 window
gl ead uffer(GL ONT) / select the front buf /
glPixelStorei(GL PAC AL GNM NT, 1) / alighment 1 /
Write into rame uffer Scope of uffer Writing Define Lower Left Corner The Procedure of uffer Writing
Specify as position (as the lower left corner) in the Select the destination buffer
Write data into a of a buffer Write data into a rectangle in a buffer
current buffer / Select front buffer as destination /
Procedure window
//window height 00 Define unpack alignment
Select the destination buffer, back or front
Define lower left corner
Define unpack alignment
Define the lower left corner
Write data into the destination
Write the data (S , S , //Data size
GL G A, // channels
GL UNS GN D T , //Data type
) //source