Mickaël Sereno mickael.serneo@inria.fr Graphics Memory Mickaël Sereno mickael.serneo@inria.fr 11/07/2019 Mickaël Sereno - mickael.sereno@inria.fr.

Slides:



Advertisements
Similar presentations
Chapter 11. Faster Geometry Throughput Presented by Garrett Yeh.
Advertisements

Vertex Buffer Objects, Vertex Array Objects, Pixel Buffer Objects.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
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.
L16: Sorting and OpenGL Interface
As well as colors, normals, and other vertex data PUSHIN’ GEO TO THE GPU JEFF CHASTINE 1.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
The programmable pipeline Lecture 10 Slide Courtesy to Dr. Suresh Venkatasubramanian.
CSE 381 – Advanced Game Programming Basic 3D Graphics
GAM531 DPS931 – Week 10 Meshes and Buffers. Breaking Down An Image Actors Actors = Mesh + Material Mesh = Shape of the object.
Advanced Computer Graphics March 06, Grading Programming assignments Paper study and reports (flipped classroom) Final project No written exams.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
OpenGL Buffer Transfers Patrick Cozzi University of Pennsylvania CIS Spring 2012.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
OPENGL INTRODUCTION 林宏祥 2014/10/06. 此投影片已被稍微簡化過,跟今日課堂上的內容不太一樣。 如果想要看更詳細說明的人,請參考每頁投影片下面的『備忘稿』
OpenGL Shader Language Vertex and Fragment Shading Programs.
1 3D API OPENGL ES v1.0 Owned by Silicon Graphics (SGL) Control was then transferred to Khronos Group Introduction.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 OGRE Programming Intermediate Tutorial: Volume Selection.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
The Graphics Pipeline Revisited Real Time Rendering Instructor: David Luebke.
A study of efficiency INDEX BUFFERS JEFF CHASTINE 1.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
Our Graphics Environment Landscape Rendering. Hardware  CPU  Modern CPUs are multicore processors  User programs can run at the same time as other.
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
Arrays Chapter 7.
Hank Childs, University of Oregon Oct. 28th, 2016 CIS 441/541: Introduction to Computer Graphics Lecture 16: textures.
Pushin’ Geo to the GPU As well as colors, normals, and other vertex data Made by Jeff Chastine, Modified by Chao Mei Jeff Chastine.
Interactive Computer Graphics CS 418 – Fall 2017 Indexed Meshes Transformations Background Imagery:
Programmable Shaders Dr. Scott Schaefer.
Photorealistic Rendering vs. Interactive 3D Graphics
Week 2 - Friday CS361.
Real-Time Rendering Buffers in OpenGL 3.3
Polygons, Transformations, and Arrays
Computer Graphics Index Buffers
Graphics on GPU © David Kirk/NVIDIA and Wen-mei W. Hwu,
Database Management Systems (CS 564)
Graphics Processing Unit
Real-Time Rendering Geometry and Buffers
Introduction to OpenGL
Chapter 6 GPU, Shaders, and Shading Languages
Advanced Programming Behnam Hatami Fall 2017.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Chapter VI OpenGL ES and Shader
Graphics Processing Unit
Building Models Ed Angel Professor Emeritus of Computer Science
HW for Computer Graphics
Computer Graphics Practical Lesson 7
Vertex Array Objects & Buffer Objects
Computer Graphics Practical Lesson 8
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Data Structures & Algorithms
Geometric Objects and Transformations (I)
Mickaël Sereno Shaders Mickaël Sereno 25/04/2019 Mickaël Sereno -
Computer Graphics Introduction to Shaders
Introduction to OpenGL
CS 480/680 Computer Graphics GLSL Overview.
CS 480/680 (Fall 2018) Part 2: Texture Loading
Opengl implementation
Computer Graphics Vertex Array Object
CIS 6930: Chip Multiprocessor: GPU Architecture and Programming
Presentation transcript:

Mickaël Sereno mickael.serneo@inria.fr Graphics Memory Mickaël Sereno mickael.serneo@inria.fr 11/07/2019 Mickaël Sereno - mickael.sereno@inria.fr

Mickaël Sereno - mickael.sereno@inria.fr Introduction « Device » memory (GPU memory) Copy « Host » memory (RAM) Pre-requisite : Copy the « Host » memory to the « Device » device memory. Do this the minimum possible. Less the communication between these two, more the program will be efficient. 11/07/2019 Mickaël Sereno - mickael.sereno@inria.fr

Graphics Memory: VBO ALL THESE VARIABLES ARE NOT ALLWAYS NECESSARY !!! VBO : Vertex Buffer Object. It is a Buffer containing the memory used by the graphics card, used for the Vertices (Points) The graphics card works only with triangles or lines (the last is less used). Usual types of variables used in programs : Position Normal UV mapping Color ALL THESE VARIABLES ARE NOT ALLWAYS NECESSARY !!! Source : Wikipédia https://en.wikipedia.org/wiki/UV_mapping 11/07/2019 Mickaël Sereno - mickael.sereno@inria.fr

Graphics Memory : VBO Two way of packing Device memory V1 N1 UV1 V2 N2 UV2 V3 N3 UV3 Forms a triangle (three points). Each point contains a position, a UV and a normal. Each of these variables can have one, two of three components per value (vector) Device memory V1 V2 V3 N1 N2 N3 UV1 UV2 UV3 Each color represents a point First we pack ALL the positions, then ALL the normals and finally ALL the UVs It is usually like this we packed the vertex values because we can modify directly one type of variable in one call (modify the beginning, middle or the end of the buffer) 11/07/2019 Mickaël Sereno - mickael.sereno@inria.fr

Graphics Memory : VBO Example in OpenGL 3.0 //We generate our buffer GLuint myBuffer; glGenBuffers(1, &myBuffer); //We fill this buffer as a GL_ARRAY_BUFFER (buffer containing vertices (points) information). //Remind to close this buffer for not misusing it(glBindBuffer(GL_ARRAY_BUFFER, 0);) glBindBuffer(GL_ARRAY_BUFFER, myBuffer); //target (GL_ARRAY_BUFFER), length, data, use case. The data size must not be superior than the buffer size, and not superior than « vertices » length, or a segmentation fault can be thrown. Here we considerate that vertices is typed « float* » (array of float) with at least 3*nbVertices values. glBufferData(GL_ARRAY_BUFFER, 3*sizeof(float)*nbVertices, vertices, GL_DYNAMIC_DRAW); //GL_DYNAMIC_DRAW signifies that we can update this buffer later if necessary glBindBuffer(GL_ARRAY_BUFFER, 0) //Not mandatory, but recommended. We close the buffer for not misusing it //TODO do your thing glDeleteBuffers(1, &myBuffer); //Delete at the end the buffer 11/07/2019 Mickaël Sereno - mickael.sereno@inria.fr

Graphics Memory : VBO Example in OpenGL 3.0 //We generate our buffer GLuint myBuffer; glGenBuffers(1, &myBuffer); //We fill this buffer as a GL_ARRAY_BUFFER (buffer containing vertices (points) information). //Remind to close this buffer for not misusing it(glBindBuffer(GL_ARRAY_BUFFER, 0);) glBindBuffer(GL_ARRAY_BUFFER, myBuffer); //2 coordinates per UV, 3 per normal and 3 per position. We do not yet copy these data (hence the NULL) glBufferData(GL_ARRAY_BUFFER, (2 + 3 + 3) * sizeof(float)*nbVertices, NULL, GL_DYNAMIC_DRAW); //Copy one by one the data (first positions, then normals and finally UV). //We remind that we do not necessarily need all of these variables, and that other variables may be needed for your usecase //parameters : Target, buffer offset, size to copy, CPU data. //We consider that each data are typed « float* » with sizeof(float)*nbVertices*nbCoordinate bytes where nbCoordinate = 2 or 3 following the number of components per value for this variable glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float)*3*nbVertices, vertices); glBufferSubData(GL_ARRAY_BUFFER, 3*sizeof(float)*nbVertices, 3*sizeof(float)*nbVertices, normals); glBufferSubData(GL_ARRAY_BUFFER, 3*3sizeof(float)*nbVertices, 2*sizeof(float)*nbVertices, uvData); glBindBuffer(GL_ARRAY_BUFFER, 0) //Close the buffer //TODO do your thing glDeleteBuffers(1, &myBuffer); //Delete at the end the buffer 11/07/2019 Mickaël Sereno - mickael.sereno@inria.fr

Mickaël Sereno - mickael.sereno@inria.fr Graphics Memory: EBO EBO : Element Buffer Object. This is a buffer telling what points forms a triangle (the EBO indexes the triangle). We can (its optional) use the EBO if we want to reuse vertices -> less memory used. VBO, out data. It is the EBO which tells in what order these data has to be read to form triangles V1 N1 UV1 V2 N2 UV2 V3 N3 UV3 EBO. Use the vertices « 1 », « 3 » et « 2 » IN THAT ORDER to form the triangle. The order is really important due to the culling process in the rendering pipeline 1 3 2 11/07/2019 Mickaël Sereno - mickael.sereno@inria.fr

Graphics Memory : EBO Example in OpenGL 3.0 //Generate the buffer GLuint myBuffer; glGenBuffers(1, &myBuffer); //Fill the buffer as a GL_ELEMENT_BUFFER (buffer containing the order of reading in the VBO). //Remember to close the buffer (glBindBuffer(GL_ELEMENT_BUFFER, 0);) glBindBuffer(GL_ELEMENT_BUFFER, myBuffer); //target (GL_ELEMENT_BUFFER), size, data, usecase. glBufferData(GL_ELEMENT_BUFFER, 3*sizeof(int)*nbTriangles, triangles, GL_DYNAMIC_DRAW); //Each index is an int. 3 points per triangles glBindBuffer(GL_ELEMENT_BUFFER, 0) //Close the buffer glDeleteBuffers(1, &myBuffer); 11/07/2019 Mickaël Sereno - mickael.sereno@inria.fr