1
Computer Graphics
Marco Tarini
Università dell’Insubria Corso di Laurea in Informatica Anno Accademico 2014/15
Meshes? In Video RAM !
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 4 / 1 5 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Reminder: Colli di bottiglia...
Fr am m en ti & at tri bu ti in te rp ol at i
Screen buffer
rasterizer lines rasterizer
triangles rasterizer points
co m pu ta zi on i pe r f ra m m en to
Qui? Allora applicazione
“transofrm limited”
(o “gemoetry limited”)
QUI?
Allora applicazione
“fill limited”
(pipeline di rendering semplificata)
Ve rti ci & lo ro a ttr ib ut i Ve rti ci p or ie tta ti & at tri bu ti co m pu ta ti co m pu ta zi on i pe r v er tic e
Reminder:
Schema (semplificato) di: “PC con scheda video”
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 4 / 1 5 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
BUS
CPU
ALU
(central)
RAM
Disk Scheda video
…
bus interno bus interno
(scheda video) (sch. video) RAM GPU
a.k.a.
System RAM or CPU RAM
a.k.a.
Video RAM or GPU RAM
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 4 / 1 5 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Colli di bottiglia:
può essere anche la comunicazione!
Fr am m en ti & at tri bu ti in te rp ol at i
Screen buffer
rasterizer lines rasterizer
triangles rasterizer points
co m pu ta zi on i pe r f ra m m en to
collo di bottiglia qui?
applicazione BUS LIMITED (o BANDWIDTH LIMITED)
Ve rti ci p or ie tta ti & at tri bu ti co m pu ta ti co m pu ta zi on i pe r v er tic e
Ve rti ci & lo ro a ttr ib ut i
SY ST EM R AM
2
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 4 / 1 5 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
“Geometry on board”
Fr am m en ti & at tri bu ti in te rp ol at i
Screen buffer
rasterizer lines rasterizer
triangles rasterizer points
co m pu ta zi on i pe r f ra m m en to
SY ST EM R AM
solo tantoogni
Ve rti ci & lo ro a ttr ib ut i Ve rti ci p or ie tta ti & at tri bu ti co m pu ta ti co m pu ta zi on i pe r v er tic e
Buffers per tenere
le mesh (in GPU RAM!)
Meshes in GPU ram
• Idea: tenere le mesh
(geometria + attributi + connettività) direttamente a bordo della RAM
della Scheda Video («video RAM», «GPU RAM»)
• Vantaggi:
– non si consuma banda (del bus fra sch. madre e video)!
• Svantaggi:
– duplicazione («mirroring») ? (SytemRAM + VideoRAM) – occhio alle modifiche
(specializzare strutture dati per mesh che si modificano spesso, e non)
• Cmq, scelta obbligata in molti API
– (fra cui vers recenti di OpenGL, WebGL, GL-ES,…)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 4 / 1 5 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Meshes in GPU ram: nelle API
• In OpenGL
– Display list (deprecate)
– Vertex Buffer Objects (VBO) + Vertex Array – …
• In WebGL – Vertex Buffers
• (geometria + attributi della mesh)
• NB: in WebGL terminology, geometry is just another attribute – Index buffer
• connettività della mesh (opzionale)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 4 / 1 5 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Back compatibility notes:
• Good old “Immediate Mode”
– Mesh in System RAM,
mandate attr. il bus vertice a vertice – Vecchia scuola OpenGL
• (deprecato da Ver 2.0 in poi)
• (non supportato in ES, WebGL)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 4 / 1 5 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
glBegin( GL_TRIANGLES );
glColor3f(1.0f, 0.0f, 0.0f); glVertex2f(0.0f, 1.0f);
glColor3f(0.0f, 1.0f, 0.0f); glVertex2f(0.87f, -0.5f);
glColor3f(0.0f, 0.0f, 1.0f); glVertex2f(-0.87f, -0.5f);
glEnd();
attrib 1movertice pos 1movertice