Buffer Objects Kurt Akeley, NVIDIA Corporation. Outline Background Buffer Objects Vertex Arrays Examples.

Slides:



Advertisements
Similar presentations
Vertex Buffer Objects, Vertex Array Objects, Pixel Buffer Objects.
Advertisements

Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Things to Remember When Developing 64-bit Software OOO "Program Verification Systems"
CS 450 Module R1. R1 Introduction In Module R1, you will implement a user interface (command handler). There are a couple of options: ▫Command Line: interface.
EECS 700: Computer Modeling, Simulation, and Visualization Dr. Shontz Chapter 2: Shader Fundamentals (continued)
Dynamic Memory Allocation I Topics Basic representation and alignment (mainly for static memory allocation, main concepts carry over to dynamic memory.
The Interface Definition Language for Fail-Safe C Kohei Suenaga, Yutaka Oiwa, Eijiro Sumii, Akinori Yonezawa University of Tokyko.
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.
CSCI 171 Presentation 11 Pointers. Pointer Basics.
Lecture 2: Object Oriented Programming I
1 Pointers A pointer variable holds an address We may add or subtract an integer to get a different address. Adding an integer k to a pointer p with base.
6/10/2015C++ for Java Programmers1 Pointers and References Timothy Budd.
1 1 Lecture 4 Structure – Array, Records and Alignment Memory- How to allocate memory to speed up operation Structure – Array, Records and Alignment Memory-
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
 2006 Pearson Education, Inc. All rights reserved Templates.
1 Introduction to Computers and Programming Quick Review What is a Function? A module of code that performs a specific job.
Programming with CUDA WS 08/09 Lecture 5 Thu, 6 Nov, 2008.
Status – Week 255 Victor Moya. Summary Command Processor. Command Processor. Memory Controller. Memory Controller. Streamer. Streamer. Vertex buffers.
ARRAYS AND POINTERS Although pointer types are not integer types, some integer arithmetic operators can be applied to pointers. The affect of this arithmetic.
Status – Week 254 Victor Moya. Summary Command Processor. Command Processor. Memory Controller. Memory Controller. Streamer. Streamer. Vertex buffers.
The programmable pipeline Lecture 10 Slide Courtesy to Dr. Suresh Venkatasubramanian.
Status – Week 252 Victor Moya. Summary Command Processor. Command Processor. Memory Controller. Memory Controller. Streamer. Streamer. Rasterizer. Rasterizer.
Embedded ‘C’.  It is a ‘mid-level’, with ‘high-level’ features (such as support for functions and modules), and ‘low-level’ features (such as good access.
Data Access Patterns. Motivation Most software systems require persistent data (i.e. data that persists between program executions). In general, distributing.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Dynamic Memory Allocation Conventional array and other data declarations An incorrect attempt to size memory dynamically Requirement for dynamic allocation.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
1-1 NET+OS Software Group Flash API Multiple flash memory bank support New Flash API introduction Detailed Flash API Function presentation Supporting.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 12: Pointers continued, C strings.
Copyright  Hannu Laine C++-programming Part 3 Hannu Laine.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
OpenGL-ES 3.0 And Beyond Boston What is EGL? EGL handles: –provides available surface specifications –context management –surface binding –render.
Slide: 1 Copyright © AdaCore Subprograms Presented by Quentin Ochem university.adacore.com.
Pointers OVERVIEW.
OpenGL Buffer Transfers Patrick Cozzi University of Pennsylvania CIS Spring 2012.
1 Chapter 15-2 Pointers, Dynamic Data, and Reference Types Dale/Weems.
Object-Oriented Programming in C++
Page 1 Remote Procedure Calls Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
C Functions Three major differences between C and Java functions: –Functions are stand-alone entities, not part of objects they can be defined in a file.
CPSC 252 The Big Three Page 1 The “Big Three” Every class that has data members pointing to dynamically allocated memory must implement these three methods:
Chapter 9 Classes: A Deeper Look, Part I Part II.
POINTERS.
CS 261 – Data Structures C Pointers Review. C is Pass By Value Pass-by-value: a copy of the argument is passed in to a parameter void foo (int a) { a.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
POINTERS. // Chapter 3 - Program 1 - POINTERS.CPP #include int main() { int *pt_int; float *pt_float; int pig = 7, dog = 27; float x = , y = 32.14;
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 1 due Friday, 7pm. RAD due next Friday. Presentations week 6. Today: –More details on functions,
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – August 23, 2001.
DFS DBufferCache DBuffer VirtualDisk startRequest(dbuf, r/w) ioComplete() blockID = getBlockID() buf[] = getBuffer() read(), write() startFetch(), startPush()
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
VAR/Fence: Using NV_vertex_array_range and NV_fence Cass Everitt.
Pointers. The memory of your computer can be imagined as a succession of memory cells, each one of the minimal size that computers manage (one byte).
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 11: Pointers.
Pointer Variables A pointer is a variable that contains a memory address The address is commonly the location of another variable in memory This pointer.
Chapter 10 Chapter 10 Implementing Subprograms. Implementing Subprograms  The subprogram call and return operations are together called subprogram linkage.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
Examples (D. Schmidt et al)
Information and Computer Sciences University of Hawaii, Manoa
Functions Students should understand the concept and basic mechanics of the function call/return pattern from CS 1114/2114, but some will not. A function.
Dynamic Storage Allocation
Real-Time Rendering Buffers in OpenGL 3.3
Computing with C# and the .NET Framework
CSCI206 - Computer Organization & Programming
Conversions of the type of the value of an expression
CSE 351: The Hardware/Software Interface
Corresponds with Chapter 5
Presentation transcript:

Buffer Objects Kurt Akeley, NVIDIA Corporation

Outline Background Buffer Objects Vertex Arrays Examples

Background Geometry transfer is too slow –Begin/End is inefficient –Vertex array memory management is poor Vendor extensions are incompatible –ATI_vertex_array_object –NV_vertex_array_range –Others ATI and NVIDIA work together –ARB_vertex_array_object Result: ARB_Vertex_Buffer_Object

Requirements High Performance –Optimize for static and dynamic data –Use the “best” memory –Provide mapped access Good Application Fit –Support mixed static/dynamic data sets –Support “mix and match” of vertex data e.g. multiple tex coord arrays for one position array e.g. constant color –Minimize code changes

Architecture Application

Architecture Application Memory + State Buffer Object

Server-side state Allows sharing between GL contexts Matches use of GPU memory Good for GLX client/server rendering Application Memory + State Buffer Object GL Server GL Client

Buffer Object Memory buffer –Array of basic machine units (bytes) –Data are in client format Small amount of state –Buffer size –Usage and access hints –Mapping state (Boolean and pointer) Data format is implicit, not explicit

Basic API void GenBuffersARB(n, *buffers); void BindBufferARB(target, buffer); void DeleteBuffersARB(n, *buffers); boolean IsBufferARB(buffer); void GetBufferParameterivARB(target, pname, *params); void GetBufferPointervARB(target, pname, **params);

Example uint buf; int parameter; GenBuffersARB(1, &buf); BindBufferARB(GL_ARRAY_BUFFER_ARB, buf); GetBufferParameterivARB(ARRAY_BUFFER_ARB, BUFFER_SIZE_ARB, &parameter); printf(“Buffer size is %d\n”, parameter); DeleteBuffers(1, &buf);

Creating a Data Store New buffer objects have no data store BufferDataARB(target, size, *data, usage) –Discards any existing data store –Creates a new data store –Optionally initializes the contents –Specifies the intended usage pattern Usage hint discussed later Data alignment is per client requirements Re-initialization is inexpensive – do it

Changing Data Store Contents Two approaches –Functional interface (set and query) –Mapping Functional –BufferSubDataARB(target, offset, size, *data) –GetBufferSubDataARB(target, offset, size, *data) –This is the default approach Static data Array data –Always a safe approach Data are never corrupted

Mapping a Buffer Object Intended for data streams void *MapBufferARB(target, access) –READ_ONLY_ARB, WRITE_ONLY_ARB, READ_WRITE_ARB –Maps the entire data store –Returns a pointer to the buffer memory –May be slow if data are copied –May result in data loss boolean UnmapBufferARB(target) –Returns true if data are uncorrupted –Invalidates pointer

Mapping Rules Specify the correct access value –Otherwise operation is undefined Be prepared for data loss –Use functional interface if this is a burden Don’t render from a mapped buffer –The error INVALID_OPERATION results Map for brief periods only –Map it, modify it, then unmap it Don’t pass a map pointer to the GL

Summary Buffer objects –Unformatted, server-side memory buffers –Include a small amount of state Two ways to modify buffer contents –Functional interface –Direct mapping Very general mechanism –Could work for any GL data stream –Implemented for vertex arrays

Vertex Arrays Vertex arrays are application state Two-step process –App specifies array locations and formats –GL pulls vertex data from arrays Goals –Store vertex arrays in buffer objects –Maximize flexibility –Avoid misuse of the mapping pointer –Avoid a cluttered, incompatible API

Per-Array Buffer Specification VertexPointer(size, type, stride, *pointer); size type stride pointer buffer ARRAY_BUFFER_ARB offset

Client and Server State Application Buffer Objects GL ServerGL Client size type stride pointer buffer ARRAY_BUFFER_ARB size type stride pointer buffer size type stride pointer buffer size type stride pointer buffer Buffer objects are server state Vertex arrays parameters are client state Memory + State

Usage Terms Stream –Specify once –Render once Static –Specify once –Render repeatedly Dynamic –Everything else –Specify/modify repeatedly –Render repeatedly

Usage Terms Application Memory + State Read Copy Draw

Usages STREAM_DRAWSTREAM_READSTREAM_COPY STATIC_DRAWSTATIC_READSTATIC_COPY DYNAMIC_DRAWDYNAMIC_READDYNAMIC_COPY Draw ReadCopy Stream Static Dynamic Vertex Array Usage

Example #define BUFFER_OFFSET(i) ((char *)NULL + (i)) + (i)) data = malloc(320);... // Fill system memory buffer BindBufferARB(ARRAY_BUFFER_ARB, 1); BufferDataARB(ARRAY_BUFFER_ARB, 320, data, STATIC_DRAW_ARB); free(data); while (...) { BindBufferARB(ARRAY_BUFFER_ARB, 1); // must precede pointer cmds VertexPointer(4, FLOAT, 0, BUFFER_OFFSET(0)); ColorPointer(4, UNSIGNED_BYTE, 0, BUFFER_OFFSET(256)); EnableClientState(VERTEX_ARRAY); EnableClientState(COLOR_ARRAY); DrawArrays(TRIANGLE_STRIP, 0, 16);... // Other rendering commands }

Notes Index arrays are supported –ELEMENT_ARRAY_BUFFER_ARB Other extensions are supported – EXT_vertex_shader – ARB_vertex_program –... Display lists are not supported intptr and sizeofptr types are introduced GLX protocol is not yet defined

Tips Keep static and dynamic data in separate buffer objects Keep vertex and index data separate Bind to the “correct” target Reinitialize data buffers Use mapping carefully –stream data –volatile memory More extensions coming soon (PBO)