A New Object Model for OpenGL

Slides:



Advertisements
Similar presentations
EECS 700: Computer Modeling, Simulation, and Visualization Dr. Shontz Chapter 2: Shader Fundamentals (continued)
Advertisements

CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Paper by: A. Balmin, T. Eliaz, J. Hornibrook, L. Lim, G. M. Lohman, D. Simmen, M. Wang, C. Zhang Slides and Presentation By: Justin Weaver.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Immutable Objects and Classes.
Visual Web Information Extraction With Lixto Robert Baumgartner Sergio Flesca Georg Gottlob.
Object-Oriented Databases
Structured Data Types and Encapsulation Mechanisms to create new data types: –Structured data Homogeneous: arrays, lists, sets, Non-homogeneous: records.
Names and Bindings Introduction Names Variables The concept of binding Chapter 5-a.
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Interpreted Declarative Representations of Task Knowledge June 21, 2012 Randolph M. Jones, PhD.
Next-Generation Graphics APIs: Similarities and Differences Tim Foley NVIDIA Corporation
OpenGL Performance John Spitzer. 2 OpenGL Performance John Spitzer Manager, OpenGL Applications Engineering
OpenGL Buffer Transfers Patrick Cozzi University of Pennsylvania CIS Spring 2012.
CSS BEST PRACTICES.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Pattern Bridge. Definition Bridge is the structural pattern that separates abstraction from the implementation so that both of them can be changed independently.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
VAR/Fence: Using NV_vertex_array_range and NV_fence Cass Everitt.
ODATA DESIGN PRINCIPLES July 26, BUILD ON HTTP, REST OData is a RESTful HTTP Protocol Build on HTTP Entities modeled as Resources Relationships.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
NetCDF Data Model Details Russ Rew, UCAR Unidata NetCDF 2009 Workshop
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 5 Examples 1.
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
Best Practices for Multi-threading Eric Young Developer Technology.
Directions in Linux OpenGL
Examples (D. Schmidt et al)
Object Lifetime and Pointers
Principles of programming languages 10: Object oriented languages
Egyptian Language School Computer Department
Visit for more Learning Resources
Textures, Sprites, and Fonts
Game Architecture Rabin is a good overview of everything to do with Games A lot of these slides come from the 1st edition CS 4455.
The Object-Oriented Database System Manifesto
Real-Time Rendering Buffers in OpenGL 3.3
Compiler Construction (CS-636)
The Basics: HTML5, Drawing, and Source Code Organization
Informatica PowerCenter Performance Tuning Tips
Introduction to Custom Templates
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Classes.
Flash EEPROM Emulation Concepts
8 Pointers.
The Small batch (and Other) solutions in Mantle API
CSS BEST PRACTICES.
Chapter 9 :: Subroutines and Control Abstraction
AVG 24th 2015 ADVANCED c# - part 1.
7 Arrays.
Built in Fairfield County: Front End Developers Meetup
CIS16 Application Development – Programming with Visual Basic
Computer Architecture
The Procedure Abstraction Part V: Run-time Structures for OOLs
10.2 const (Constant) Objects and const Member Functions
Introduction to Classes and Objects
Closure Representations in Higher-Order Programming Languages
DB Implementation: MS Access Forms
Working with Text and Cascading Style Sheets
Introduction to Shaders
619 Final Review Fall 2017 Professor Ammann.
Building ASP.NET Applications
CISC/CMPE320 - Prof. McLeod
7 Arrays.
Debugging Tools Tim Purcell NVIDIA.
Diving into Query Execution Plans
COMPILERS Semantic Analysis
point when a program element is bound to a characteristic or property
Language Definitions Chap. 3 of Orange Book.
File System Performance
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Presentation transcript:

A New Object Model for OpenGL Michael Gold NVIDIA Corporation

Why do we need a new object model? Existing object model evolved, was never designed Began with display lists Texture objects started down wrong path New semantics with each extension Optimized for object creation Most apps create once, reference often Name / pointer translation typically 3-5% of runtime Bind to edit / bind to use Complex “side effects” cause application errors Object mutability too flexible Burden on implementation to support Application misuse / thrashing Sharing is problematic “All or nothing” lacks useful granularity Dangerous race conditions Ill-defined orphaning behavior

New object model basics Object ID generated by the implementation No more “push” model Immediate feedback on success of creation Eliminates ambiguous “orphaning” behavior New data types Strong type checking May be pointer (faster lookup, faster error detection!) Manipulator functions take an object ID No more “bind to edit” Immutability removes most editing anyway More intuitive / fewer side effects Per-object sharing No more “all or nothing” Objects are not shared by default

Immutability Object structure fixed at creation time Create new instead of edit existing Contents may be modified Atomic creation removes “guesswork” Read-only structure eliminates dangerous race conditions Easier to program Fewer points of failure Easier to optimize No driver heuristics necessary What’s good for us is good for you!

Attribute Objects Client state Mutable Extensible May be reused for multiple objects Extensible Opaque data structure Watch for memory leaks // Create an attribute object, initialized to defaults GLattribute attrib = glCreateAttrib(WIDGET_OBJECT); // Override defaults as necessary glSetAttribi(attrib, PROPERTY, value); … // Create the actual object Object = glCreateWidget(attrib); // Destroy attribute object glDestroyObject(attrib);

Image Objects Replace textures and render buffers Size, shape, format fixed at creation time Data is mutable Always “complete” GLattribute attrib = glCreateAttrib(GL_IMAGE_OBJECT); glSetAttribo(attrib, GL_FORMAT, format); glSetAttribi(attrib, GL_WIDTH, width); glSetAttribi(attrib, GL_HEIGHT, height); glSetAttribi(attrib, GL_LEVELS, levels); GLimage image = glCreateImage(attrib); glDestroyObject(attrib); - or - image = gluCreateImage2D(format, width, height, levels);

Sampler Objects Replaces TexParameter Separate from Image Object Samplers may be bound to multiple image objects Images may be bound to multiple sampler objects GLattribute attrib = glCreateAttrib(GL_SAMPLER_OBJECT); glSetAttribo(attrib, GL_MIN_FILTER, min_filter); glSetAttribi(attrib, GL_MAG_FILTER, mag_filter); glSetAttribi(attrib, GL_WRAP_S, wrap_s); glSetAttribi(attrib, GL_WRAP_T, wrap_t); GLsampler sampler = glCreateSampler(attrib); glDestroyObject(attrib); - or - sampler = gluCreateSampler2D(min_filter, mag_filter, wrap_s, wrap_t);

Program Objects Shader object is compiled representation of text string Trivial “immutable” object // shaderType is VERTEX or FRAGMENT; source is text string shader = gluCreateShader(shaderType, source); Program links together one or more shader(s) No incremental relinking (create a new program instead) glSetAttribov(attrib, GL_SHADERS, count, shader_list); Uniforms may be declared “const” prior to linking Hint may allow greater optimization Comparable to #define Optimize “uber shaders” glSetNamedAttribf(attrib, GL_UNIFORM_CONSTANT, “decay”, 0.2f);

Uniform objects Uniform storage separate from program object Uniform values are data (mutable) Enables rapid updates of uniform values Toggle between multiple state vectors Create “default” uniform object from linked program Contains exact set of uniforms required for the program Create custom uniform groups prior to linking Uniform objects sharable between programs Image and Sampler objects bind to uniform objects Solves the 32 texture limit No more ActiveTexture / BindTexture

Other object types Format objects Framebuffer objects Buffer objects More expressive than simple enumerants Framebuffer objects Includes “format compatibility” query mechanism Always complete! Buffer objects Now, with 50% more immutability! Usage no longer a hint Vertex Array objects Encapsulates all array state for fast state changes Immutability removes validation overhead Synchronization objects Asynchronous description Display lists? Stay tuned…