Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

OpenGL 3.2 and More


Published on

Presented September 30, 2009 in San Jose, California at GPU Technology Conference.

Describes the new features of OpenGL 3.2 and NVIDIA's extensions beyond 3.2 such as bindless graphics, direct state access, separate shader objects, copy image, texture barrier, and Cg 2.2.

Published in: Technology, Art & Photos
  • OpenGL Superbible: Comprehensive Tutorial and Reference (7th Edition) ---
    Are you sure you want to  Yes  No
    Your message goes here
  • OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3 (8th Edition) ---
    Are you sure you want to  Yes  No
    Your message goes here
  • Anton's OpenGL 4 Tutorials ---
    Are you sure you want to  Yes  No
    Your message goes here

OpenGL 3.2 and More

  1. San Jose | September 30, 2009 | Mark J. Kilgard, NVIDIA Corporation <ul><li>OpenGL 3.2 and More </li></ul>
  2. Mark J. Kilgard <ul><li>Principal System Software Engineer </li></ul><ul><ul><li>OpenGL driver </li></ul></ul><ul><ul><li>Cg shading language </li></ul></ul><ul><li>OpenGL Utility Toolkit (GLUT) implementer </li></ul><ul><li>co-author of Cg Tutorial </li></ul>
  3. Overview <ul><li>OpenGL 3.2 </li></ul><ul><ul><li>Available today </li></ul></ul><ul><ul><li>What’s in it? </li></ul></ul><ul><li>NVIDIA’s additional functionality </li></ul><ul><ul><li>Above & beyond OpenGL 3.2 </li></ul></ul>
  4. A brief 2-slide review of OpenGL 3.0 & 3.1 Before we get really started… You are already familiar and using OpenGL 3.1 aren’t you??
  5. For review, OpenGL 3.0 <ul><li>Texturing </li></ul><ul><ul><li>Integer & floating-point texture formats </li></ul></ul><ul><ul><li>Compact floating-point formats </li></ul></ul><ul><ul><li>sRGB color space texture formats </li></ul></ul><ul><ul><li>1- and 2-component compressed texture formats </li></ul></ul><ul><ul><li>1D and 2D texture array targets </li></ul></ul><ul><li>Miscellaneous </li></ul><ul><ul><li>Vertex array objects </li></ul></ul><ul><ul><li>Conditional rendering </li></ul></ul><ul><ul><li>Multisample-aware stretch blits </li></ul></ul><ul><ul><li>Fine control over mapping & flushing buffer sub-ranges </li></ul></ul><ul><li>Framebuffer functionality </li></ul><ul><ul><li>Render-to-texture with framebuffer objects </li></ul></ul><ul><ul><li>sRGB blending </li></ul></ul><ul><ul><li>Packed depth/stencil formats for render-buffers (and texturing) </li></ul></ul><ul><ul><li>Per-color-attachment blend enables and color write masks </li></ul></ul><ul><li>Shader improvements </li></ul><ul><ul><li>OpenGL Shading Language 1.30 </li></ul></ul>
  6. For review, OpenGL 3.1 <ul><li>Texturing </li></ul><ul><ul><li>Guarantees 16 texture units </li></ul></ul><ul><ul><li>Texture buffer objects </li></ul></ul><ul><ul><li>Texture rectangle target: 2D image with [0..width, 0..height] coordinate space </li></ul></ul><ul><ul><li>Signed normalized texture formats </li></ul></ul><ul><li>Miscellaneous </li></ul><ul><ul><li>Fast data copying between buffer objects </li></ul></ul><ul><ul><li>Primitive restart index for vertex arrays </li></ul></ul><ul><li>Shader improvements </li></ul><ul><ul><li>OpenGL Shading Language 1.40 </li></ul></ul><ul><ul><li>Shader can access uniform values from buffer objects </li></ul></ul><ul><ul><li>Instanced rendering provides instance counter to vertex shader </li></ul></ul>
  7. OpenGL 3.2 modern GPU functionality, platform portability, API maturity & completeness
  8. From the 1994 OpenGL 1.1 Data Flow… vertex processing rasterization & fragment coloring texture raster operations framebuffer pixel unpack pixel pack vertex puller client memory pixel transfer glReadPixels / glCopyPixels / glCopyTex{Sub}Image glDrawPixels glBitmap glCopyPixels glTex{Sub}Image glCopyTex{Sub}Image glDrawElements glDrawArrays selection / feedback / transform feedback glVertex* glColor* glTexCoord* etc. blending depth testing stencil testing accumulation storage access operations
  9. … OpenGL 1.0 in detail Vertex processing Pixel processing Texture mapping Image primitive processing Pixel unpacking Pixel packing Vertex assembly texture image specification image rectangles, bitmaps primitive topology, transformed vertex data stenciling, depth testing, blending, accumulation pixel image primitive batch type, vertex attributes primitive batch type, vertex data fragment texture fetches pixel image or texture image specification image and bitmap fragments point, line, and polygon fragments pixels to pack unpacked pixels pixels fragments filtered texels buffer data vertices Legend programmable operations fixed-function operations copy pixels, copy texture image Fragment processing Geometric primitive assembly & processing Raster operations Framebuffer Command parser
  10. … to the 2009 OpenGL 3.2 Data Flow Vertex processing Pixel processing Texture mapping Geometric primitive assembly & processing Image primitive processing Transform feedback Pixel unpacking Pixel packing Vertex assembly pixels in framebuffer object textures texture buffer objects texture image specification image rectangles, bitmaps primitive topology, transformed vertex data vertex texture fetches pixel pack buffer objects pixel unpack buffer objects vertex buffer objects transform feedback buffer objects buffer data, unmap buffer geometry texture fetches primitive batch type, vertex indices, vertex attributes primitive batch type, vertex data fragment texture fetches pixel image or texture image specification map buffer, get buffer data transformed vertex attributes image and bitmap fragments point, line, and polygon fragments pixels to pack unpacked pixels pixels fragments filtered texels buffer data vertices Legend programmable operations fixed-function operations copy pixels, copy texture image Buffer store uniform/ parameters buffer objects Fragment processing stenciling, depth testing, blending, accumulation Raster operations Framebuffer Command parser
  11. Buffer Centric View of OpenGL Vertex Array Buffer Object (VaBO) Transform Feedback Buffer (XBO) Parameter Buffer (PaBO) Pixel Unpack Buffer (PuBO) Pixel Pack Buffer (PpBO) Bindable Uniform Buffer (BUB) Texture Buffer Object (TexBO) Vertex Puller Vertex Shading Geometry Shading Fragment Shading Texturing Array Element Buffer Object (VeBO) Pixel Pipeline vertex data texel data pixel data parameter data ( not ARB functionality yet ) glBegin, glDrawElements, etc. glDrawPixels, glTexImage2D, etc. glReadPixels, etc. Framebuffer
  12. OpenGL 3.2 Functional Overview <ul><li>Direct3D-isms </li></ul><ul><ul><li>BGRA vertex component ordering </li></ul></ul><ul><ul><li>Provoking vertex convention </li></ul></ul><ul><ul><li>Drawing commands allowing modification of the base vertex index </li></ul></ul><ul><ul><li>Upper-left and lower-left fragment coordinate conventions </li></ul></ul><ul><li>Geometry shaders </li></ul><ul><ul><li>Per-primitive programmability </li></ul></ul><ul><li>Shader improvements </li></ul><ul><ul><li>OpenGL Shading Language 1.50 </li></ul></ul><ul><li>Miscellaneous </li></ul><ul><ul><li>Depth clamping, synchronization, seamless cube map filtering, multisample improvements </li></ul></ul>
  13. Direct3Disms better OpenGL & Direct3D content portability
  14. Direct3Dism Motivation <ul><li>A posteriori “3D content tied to API” scheme </li></ul><ul><ul><li>Without intending it, 3D application content gets tied to API’s conventions </li></ul></ul>Your OpenGL application OpenGL driver same GPU Direct3D driver Your OpenGL application content Your Direct3D application Your Direct3D application content OpenGL conventions Direct3D conventions content authored to OpenGL conventions content authored to Direct3D conventions OpenGL API Direct3D API hardware interface 3D API interface
  15. NVIDIA Recognizes 3D API Reality <ul><li>You decide the 3D API best for your application </li></ul><ul><ul><li>Lots of reasons to pick your API choice </li></ul></ul><ul><ul><ul><li>Target systems, intended market, cross-platform requirements, software legacy, content creation vs. deployment, etc. </li></ul></ul></ul><ul><li>Fundamentally, NVIDIA believes in Visual Computing (not APIs) </li></ul><ul><ul><li>So is essentially agnostic about your 3D API choice </li></ul></ul><ul><ul><li>OpenGL, Direct3D 9/10/11, or OpenGL ES </li></ul></ul><ul><ul><ul><li>NVIDIA provides best implementations of all options; you pick </li></ul></ul></ul><ul><li>NVIDIA’s belief in Visual Computing means </li></ul><ul><ul><li>Your 3D API choice shouldn’t tie down your 3D application or 3D content </li></ul></ul>
  16. Direct3Dism Concept <ul><li>Allows your 3D content to be API agnostic </li></ul><ul><ul><li>OpenGL supports both OpenGL & Direct3D conventions, so support either style </li></ul></ul>Your OpenGL application OpenGL driver GPU Direct3D driver Your OpenGL application content Your Direct3D application Your Direct3D application content OpenGL API Direct3D API content authored to OpenGL conventions content authored to Direct3D conventions OpenGL + Direct3D conventions Direct3D conventions hardware interface 3D API interface Direct3D conventions supported by OpenGL too
  17. OpenGL & Direct3D Conventions OpenGL 3.2 First vertex of primitive Last vertex of primitive (mostly) Provoking vertex for flat-shading OpenGL 3.2 Upper-left Lower-left Fragment coordinate origin Cg HLSL 9, 10, and 11 GLSL Shading Language syntax Convention OpenGL Direct3D Addressed by Window origin Lower-left, pixels at half-integers Upper-left, pixels on integers (DX9) pixels on half-integers (DX 10) projection matrix & front-facing re-configuration Clip space [-1…+1] 3 [-1…+1] 2 [0…1] projection matrix re-configuration 4-byte vertex color RGBA BGRA OpenGL 3.2 Shader bind granularity Linked (for GLSL) Per-domain (for Cg & assembly) Per-domain EXT_separate shader_objects Object manipulation Bind-to-edit, Bind-to-query Edit-by-name, Query-by-name EXT_direct_ state_access
  18. Dealing with API Convention Differences <ul><li>Innocuous differences </li></ul><ul><ul><li>API granularity </li></ul></ul><ul><ul><ul><li>OpenGL fine-grain state vs. Direct3D 10 state blocks </li></ul></ul></ul><ul><ul><ul><li>OpenGL selectors versus Direct3D direct state access </li></ul></ul></ul><ul><ul><li>Easily dealt with by reconfiguring existing state </li></ul></ul><ul><ul><ul><li>Examples: window origin & clip space conventions </li></ul></ul></ul><ul><li>Formidable differences </li></ul><ul><ul><li>Format differences </li></ul></ul><ul><ul><ul><li>Unsupported formats such as 4-byte BGRA vertex colors </li></ul></ul></ul><ul><ul><li>Inconsistent state management </li></ul></ul><ul><ul><ul><li>Per-domain shaders vs. monolithic GLSL shaders </li></ul></ul></ul><ul><ul><li>Shaders coded to a particular shading language syntax </li></ul></ul><ul><ul><ul><li>GLSL vs. HLSL, achieve commonality via Cg </li></ul></ul></ul><ul><ul><li>Conventions baked into shaders </li></ul></ul><ul><ul><ul><li>Fragment coordinate origin as visible from a fragment shader </li></ul></ul></ul>fairly easy to address in your application difficult to address without 3D API help
  19. Impetus for Direct3Dism Effort <ul><li>Many software companies motivated this effort </li></ul><ul><ul><li>TransGaming </li></ul></ul><ul><ul><li>Blizzard </li></ul></ul><ul><ul><li>Destineer </li></ul></ul><ul><ul><li>Aspyr </li></ul></ul><ul><ul><li>CodeWeavers </li></ul></ul><ul><li>Direct result of feedback from 3D software engineers </li></ul><ul><ul><li>Yes, you can influence OpenGL’s direction & course </li></ul></ul>
  20. Supporting Direct3Disms Not New to OpenGL <ul><li>OpenGL has always supported multiple formats well </li></ul><ul><ul><li>OpenGL’s plethora of pixel and vertex formats </li></ul></ul><ul><ul><li>Very first OpenGL extension: EXT_bgra </li></ul></ul><ul><ul><ul><li>Provides a pixel component ordering to match the color component ordering of Windows for 2D GDI rendering </li></ul></ul></ul><ul><ul><ul><li>Made core functionality by OpenGL 1.3 </li></ul></ul></ul><ul><li>Many OpenGL extensions have embraced Direct3Disms </li></ul><ul><ul><li>Secondary color </li></ul></ul><ul><ul><li>Fog coordinate </li></ul></ul><ul><ul><li>Point sprites </li></ul></ul><ul><ul><li>OpenGL 3.0’s fine-grain buffer mapping </li></ul></ul>
  21. BGRA Vertex Array Order <ul><li>Direct3D 9’s most common usage for per-vertex colors is 32-bit D3DCOLOR data type: </li></ul><ul><ul><li>Red in bits 16:23 </li></ul></ul><ul><ul><li>Green in bits 8:15 </li></ul></ul><ul><ul><li>Blue in bits 0:7 </li></ul></ul><ul><ul><li>Alpha in bits 24:31 </li></ul></ul><ul><li>Laid in memory, looks like BGRA order </li></ul><ul><ul><li>OpenGL assumes RGBA order for all vertex arrays </li></ul></ul><ul><ul><li>However Direct3D colors not stored in packed unsigned bytes have RGBA order </li></ul></ul><ul><li>Direct3Dism EXT_vertex_array_bgra extension allows: glColorPointer( GL_BGRA , GL_UNSIGNED_BYTE, stride, pointer); glSecondaryColorPointer( GL_BGRA , GL_UNSIGNED_BYTE, stride, pointer); glVertexAttribPointer( GL_BGRA , GL_UNSIGNED_BYTE, stride, pointer); </li></ul>8-bit red 8-bit alpha 8-bit green 8-bit blue bit 31 bit 0
  22. Provoking Vertex Order Conventions <ul><li>Direct3D uses “first” vertex of a triangle or line to determine which color is used for flat shading </li></ul><ul><li>OpenGL uses “last” vertex for lines, triangles, and quads </li></ul><ul><ul><li>Except for polygons ( GL_POLYGON ) mode that use the first vertex </li></ul></ul>Direct3D 9 pDev->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT); OpenGL glShadeModel(GL_FLAT); Input triangle strip with per-vertex colors
  23. Configurable Provoking Vertex <ul><li>Easy-to-use API </li></ul><ul><ul><li>New command glProvokingVertex // “native” OpenGL convention glProvokingVertex(GL_LAST_VERTEX_CONVENTION); // Direct3D convention glProvokingVertex(GL_FIRST_VERTEX_CONVENTION); </li></ul></ul><ul><ul><li>OpenGL 3.2 promotion of EXT_provoking_vertex extension </li></ul></ul><ul><li>Affects </li></ul><ul><ul><li>fixed-function glShadeModel </li></ul></ul><ul><ul><li>flat shaded attributes for fragment shaders </li></ul></ul><ul><ul><li>geometry shaders that emit flat shaded attributes </li></ul></ul>
  24. Provoking Vertex Details <ul><li>Provoking vertex sounds really obscure </li></ul><ul><ul><li>Technically shade model is part of “deprecated” feature set of OpenGL </li></ul></ul><ul><ul><li>However very common mode for real-time strategy games </li></ul></ul><ul><ul><ul><li>Many, many objects drawn this way </li></ul></ul></ul><ul><ul><ul><li>Very difficult for application to “juggle” vertex data to match API’s native provoking vertex convention </li></ul></ul></ul><ul><ul><ul><ul><li>Particularly when using vertex buffer objects </li></ul></ul></ul></ul><ul><li>Quad behavior may vary </li></ul><ul><ul><li>Direct3D doesn’t support quadrilateral primitives </li></ul></ul><ul><ul><li>So “first vertex” provoking vertex convention may or may not apply to quadrilateral primitives </li></ul></ul><ul><ul><ul><li>GeForce 8 say true for “quads follow the convention” </li></ul></ul></ul><ul><ul><ul><li>GeForce 7 and earlier say false for “quads follow the convention” </li></ul></ul></ul><ul><ul><ul><li>Check GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION boolean if you care </li></ul></ul></ul>
  25. Provoking Vertex Behavior geometry shader primitives Last vertex convention First vertex convention Primitive type of polygon i 2i+3 2i-1 GL_TRIANGLE_STRIP_ADJACENCY 6i-1 6i-5 GL_TRIANGLE_ADJACENCY i+2 i+1 GL_LINE_STRIP_ADJACENCY 4i-1 4i-2 GL_LINES_ADJACENCY i i GL_POLYGON 2i+2 , if quads follow provoking vertex 2i+2 , if not 2i-1 2i+2 GL_QUAD_STRIP 4i , if quads follow provoking vertex 4i , if not 4i-3 4i GL_QUADS i+2 i+1 GL_TRIANGLE_FAN i+2 i GL_TRIANGLE_STRIP 3i 3i-2 GL_TRIANGLES i+1 i GL_LINE_STRIP i+1 , if i<n 1, if i=n i GL_LINE_LOOP 2i 2i-1 GL_LINES i i GL_POINT same same same same
  26. Direct3D vs. OpenGL Coordinate System Conventions <ul><li>Window origin conventions </li></ul><ul><ul><li>Direct3D = upper-left origin </li></ul></ul><ul><ul><li>OpenGL = lower-left origin </li></ul></ul><ul><li>Pixel center conventions </li></ul><ul><ul><li>Direct3D9 = pixel centers at integer locations </li></ul></ul><ul><ul><li>OpenGL and Direct3D 10 = pixel centers at half-pixel locations </li></ul></ul><ul><ul><ul><li>Makes pixel centers for rasterization “match” texel centers for texturing </li></ul></ul></ul><ul><li>Clip space conventions </li></ul><ul><ul><li>Direct3D = [-1,+1] for XY, [0,1] for Z </li></ul></ul><ul><ul><li>OpenGL = [-1,+1] range for XYZ </li></ul></ul><ul><li>Affects </li></ul><ul><ul><li>How projection matrix is loaded </li></ul></ul><ul><ul><li>Fragment shaders that access the window position </li></ul></ul><ul><ul><li>Point sprites have upper-left texture coordinate origin </li></ul></ul><ul><ul><ul><li>OpenGL already lets application choose lower-left or upper-left </li></ul></ul></ul>
  27. 3 APIs, 3 Different Window Space Conventions <ul><li>Pixel center grids coordinate systems </li></ul>OpenGL Direct3D 9 Direct3D 10 Upper-left origin Lower-left origin = pixel sample center
  28. Direct3D 9 to OpenGL <ul><li>How to go from Direct3D ’s </li></ul><ul><ul><li>[-1,+1]x[-1,+1]x[0,1] clip space to OpenGL’s [-1,+1] 3 </li></ul></ul><ul><ul><li>integer-centered pixel centers to OpenGL’s half-pixel centers </li></ul></ul><ul><li>Simple state adjustment </li></ul><ul><ul><li>Projection matrix fudge glMatrixLoadIdentityEXT(GL_PROJECTION); glMatrixScalefEXT(GL_PROJECTION, 1, -1, 2); glMatrixTranslatefEXT(GL_PROJECTION, 0.5/windowWidth, 0.5/windowHeight, -0.5); </li></ul></ul><ul><ul><li>Reverse convention for what is front-facing glFrontFace(GL_CW); // OpenGL default is GL_CCW </li></ul></ul><ul><ul><ul><li>Compensates for y-flip that reverses coordinate system’s handedness </li></ul></ul></ul><ul><li>No need for API additions to support Direct3D 9’s system </li></ul>
  29. Direct3D 10 to OpenGL <ul><li>How to go from Direct3D 10’s </li></ul><ul><ul><li>[-1,+1]x[-1,+1]x[0,1] clip space to OpenGL’s [-1,+1] 3 </li></ul></ul><ul><ul><li>where both APIs have half-pixel centers </li></ul></ul><ul><li>Simple state adjustment </li></ul><ul><ul><li>Projection matrix fudge glMatrixLoadIdentityEXT(GL_PROJECTION); glMatrixScalefEXT(GL_PROJECTION, 1, -1, 2); glMatrixTranslatefEXT(GL_PROJECTION, 0, 0, // no half-pixel shift for Direct3 10 -0.5); </li></ul></ul><ul><ul><li>Reverse convention for what is front-facing glFrontFace(GL_CW); // OpenGL default is GL_CCW </li></ul></ul><ul><ul><ul><li>Compensates for y-flip that reverses coordinate system’s handedness </li></ul></ul></ul><ul><li>Again, no need for API additions to support Direct3D 10’s system </li></ul>
  30. Fragment Coordinate Convention Usage <ul><li>Typically used in post-processing shaders Examples: </li></ul><ul><ul><li>Motion blur </li></ul></ul><ul><ul><li>Depth-of-field </li></ul></ul><ul><li>Shader assumes a particular convention for the fragment coordinate origin </li></ul><ul><ul><li>Attempting to “re-write” Direct3D shader tends to </li></ul></ul><ul><ul><ul><li>Compromise shader performance </li></ul></ul></ul><ul><ul><ul><ul><li>Introduces new “window height” uniform that must be always set correctly </li></ul></ul></ul></ul><ul><ul><ul><li>Hard to do automatically and robustly </li></ul></ul></ul><ul><li>Robust approach: Allow shader author (or automatic translator) to specify convention explicitly </li></ul>
  31. Fragment Shader Coordinate Conventions <ul><li>Required GLSL introduction #extension GL_ARB_fragment_coord_conventions : require </li></ul><ul><li>Pick one of the following GLSL declarations: // “native” OpenGL convention in vec4 gl_FragCoord; // DirectX 9 convention layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord; // DirectX 10 convention layout(origin_upper_left) in vec4 gl_FragCoord; </li></ul><ul><li>Also supported by NVIDIA assembly extensions OPTION ARB_fragment_coord_origin_upper_left; OPTION ARB_fragment_coord_pixel_center_integer; </li></ul>
  32. Deprecation there’s “old” & there’s “still supported”
  33. Deprecation – OpenGL ARB view <ul><li>OpenGL has never removed features. However, </li></ul><ul><li>After 15+ years, defining new features to work with old features becomes increasingly difficult </li></ul><ul><li>OpenGL 3.0 marks features as deprecated </li></ul><ul><ul><li>OpenGL 3.0 does not remove any features </li></ul></ul><ul><ul><li>Redundant, legacy and obsolete features </li></ul></ul><ul><ul><li>Parts of OpenGL unlikely to be accelerated </li></ul></ul><ul><ul><li>Guidance to developers to prepare for future revisions </li></ul></ul>
  34. Deprecation – OpenGL ARB view <ul><li>OpenGL 3.1 removed these deprecated features </li></ul><ul><li>Added support back with ARB_compatibility extension </li></ul><ul><li>OpenGL 3.2 formalized this in two profiles </li></ul><ul><ul><li>“ Core” profile with features removes </li></ul></ul><ul><ul><li>“ Compatibility” profile with all features present </li></ul></ul><ul><li>Implementation of “Core” mandatory </li></ul><ul><ul><li>“ Compatibility” optional </li></ul></ul>
  35. Deprecation – NVIDIA view <ul><li>Set of removed functionality is in use by applications today, helping our customer’s business </li></ul><ul><li>Using just “Core” OpenGL 3.2 is a huge effort in rewriting existing code </li></ul><ul><li>OpenGL 3.2 “Core” not offering enough incentive to re-write existing code </li></ul><ul><li>Deprecation is NOT in the best interest of ISVs and therefore not in NVIDIA’s business interest </li></ul>
  36. Deprecation – NVIDIA view <ul><li>We will not remove ANY feature from our drivers </li></ul><ul><li>OpenGL on NVIDIA will be fully backwards compatible </li></ul><ul><li>NVIDIA has and will ship the Compatibility profile </li></ul><ul><li>NVIDIA will fully support, tune and bug fix all features </li></ul><ul><li>See our public statement: </li></ul><ul><li> </li></ul>
  37. Deprecation – Myths <ul><li>Feature removal will result in a faster driver </li></ul><ul><li>Feature removal will result in a higher quality driver </li></ul><ul><li>Feature removal will result in a cleaner API </li></ul><ul><li>Not removing features means OpenGL will die </li></ul><ul><li>Only useless features were deprecated </li></ul><ul><ul><li>Far from true </li></ul></ul>
  38. So You can just ignore Deprecation <ul><li>NVIDIA values OpenGL API backward compatibility </li></ul><ul><ul><li>We don’t take API functionality away from you </li></ul></ul><ul><ul><li>We aren’t going to force you to re-write apps </li></ul></ul><ul><li>Does deprecated functionality “stay fast”? </li></ul><ul><ul><li>Yes, of course—and stays fully tested </li></ul></ul><ul><ul><li>Bottom-line: Old & new features run fast </li></ul></ul>
  39. Geometry Shaders per-primitive programmability
  40. Geometry Shaders via OpenGL <ul><li>Programmability for geometric primitives </li></ul><ul><ul><li>one geometric primitive in, zero or more primitives out </li></ul></ul><ul><li>Supported by NVIDIA’s OpenGL driver since GeForce 8 launch </li></ul><ul><ul><li>NV_gpu_program4 for assembly </li></ul></ul><ul><ul><li>Cg 2.x’s gp4gp “geometry” profile </li></ul></ul><ul><ul><li>NV_geometry_shader4 / EXT_geometry_shader4 for (GLSL) </li></ul></ul><ul><li>Standardized as an ARB extension in OpenGL 3.1 timeframe </li></ul><ul><ul><li>ARB_geometry_shader4 </li></ul></ul><ul><li>Now finally core functionality in OpenGL 3.2 </li></ul><ul><ul><li>Essentially unchanged from EXT and ARB versions </li></ul></ul>
  41. Geometry Shaders <ul><li>New programmable shader domain </li></ul><ul><ul><li>Operates on assembled primitives </li></ul></ul><ul><ul><ul><li>Triangles, lines, points, and new adjacency primitives </li></ul></ul></ul><ul><ul><li>Outputs zero or more primitives </li></ul></ul><ul><ul><ul><li>Must be point, line stripes, or triangle strips </li></ul></ul></ul><ul><ul><ul><li>Primitive restarts allowed </li></ul></ul></ul><ul><li>Warning: Not well suited for unbounded tessellation </li></ul>application Vertex shader Primitive assembly Geometry shader Rasterizer Fragment shader Raster operations framebuffer application programmable
  42. Geometry Shader Silhouette Edge Rendering silhouette edge detection geometry program Complete mesh Silhouette edges Useful for non-photorealistic rendering Looks like human sketching
  43. More Geometry Shader Examples Shimmering point sprites Generate fins for lines Generate shells for fur rendering
  44. Improved Interpolation <ul><li>Using geometry shader functionality </li></ul>Quadratic normal interpolation True quadrilateral rendering with mean value coordinate interpolation
  45. “Fair” Quadrilateral Interpolation <ul><li>glBegin(GL_QUADS); </li></ul><ul><li>glColor3fv(red); glVertex3fv(lowerLeft); </li></ul><ul><li>glColor3fv(green); glVertex3fv(lowerRight); </li></ul><ul><li>glColor3fv(red); glVertex3fv(upperRight); </li></ul><ul><li>glColor3fv(blue); glVertex3fv(upperLeft); </li></ul><ul><li>glEnd(); </li></ul><ul><li>Geometry shader actually operates on 4-vertex GL_LINE_ADJACENCY primitives instead of quads </li></ul>Wrong , slash triangle split Wrong , backslash triangle split Better : Mean value coordinates
  46. Geometry Shader-based Bump Map Setup <ul><li>Vertex shader does skinning </li></ul><ul><ul><li>Problem: how does texture-space basis for bump mapping respond to arbitrary skinning? </li></ul></ul><ul><ul><li>Solution: geometry shader constructs per-triangle texture-basis using post-skinning vertex positions and normals </li></ul></ul><ul><li>So geometry shader: </li></ul><ul><ul><li>Computes object-to-texture space basis for triangle </li></ul></ul><ul><ul><ul><li>Can account of texture mirroring in normal map </li></ul></ul></ul><ul><ul><li>Transforms object-space vectors to texture space </li></ul></ul><ul><ul><li>Outputs triangle </li></ul></ul><ul><li>Fragment shader uses texture-space normals for bump map shading </li></ul>
  47. Cg Code <ul><li>Shader performs texture-basis setup </li></ul><ul><li>Can compile to GLSL or HLSL 10 code </li></ul><ul><ul><li>Cg 2.2 feature </li></ul></ul><ul><li>See working example code in Cg 2.2 </li></ul>TRIANGLE void md2bump_geometry( AttribArray < float4 > position : POSITION , AttribArray < float2 > texCoord : TEXCOORD0 , AttribArray < float3 > objPosition : TEXCOORD1 , AttribArray < float3 > objNormal : TEXCOORD2 , AttribArray < float3 > objView : TEXCOORD3 , AttribArray < float3 > objLight : TEXCOORD4 ) { float3 dXYZdU = objPosition[1] - objPosition[0]; float dSdU = texCoord[1].s - texCoord[0].s; float3 dXYZdV = objPosition[2] - objPosition[0]; float dSdV = texCoord[2].s - texCoord[0].s; float3 tangent = normalize (dSdV * dXYZdU - dSdU * dXYZdV); float area = determinant ( float2x2 (dSTdV, dSTdU)); float3 orientedTangent = area >= 0 ? tangent : -tangent; for ( int i=0; i<3; i++) { float3 normal = objNormal[i], binormal = cross (tangent,normal); float3x3 basis = float3x3 (orientedTangent, binormal, normal); float3 surfaceLightVector : TEXCOORD1 = mul (basis, objLight[i]); float3 surfaceViewVector : TEXCOORD2 = mul (basis, objView[i]); emitVertex (position[i], texCoord[i], surfaceLightVector, surfaceViewVector); } }
  48. Geometry Shader-based Shadow Volume Generation un-shadowed bump-mapped shading via geometry shader texture-space basis setup shadow volume extrusion by geometry shader shadow region stencil multi-pass combination of shadowed and un-shadowed shading
  49. Miscellaneous some other 3.2 goodness
  50. Tripped Up By Near/Far Clipping <ul><li>Conventionally 3D APIs “clip” to near & far view frustum planes </li></ul><ul><ul><li>Results in classic artifacts </li></ul></ul><ul><ul><ul><li>Geometry is “cut open” by near clip plane </li></ul></ul></ul><ul><ul><ul><li>Naïvely moving near plane closer poorly distributes depth buffer precision </li></ul></ul></ul><ul><li>Alternatively, geometry is “lost” beyond the far clip plane </li></ul>no clipping problem closer to alien near clip plane cuts open alien head
  51. Depth Clamping to the Rescue <ul><li>Depth clamping API </li></ul><ul><ul><li>Easy to enable/disable glEnable(GL_DEPTH_CLAMP); glDisable(GL_DEPTH_CLAMP); </li></ul></ul><ul><li>What it does </li></ul><ul><ul><li>Disables near & far clip planes </li></ul></ul><ul><ul><ul><li>But this allows depth values to interpolate beyond [0,1] representable range of the depth buffer </li></ul></ul></ul><ul><ul><li>So additionally clamps interpolated values to [0,1] range </li></ul></ul>
  52. Depth Clamping Applications <ul><li>Avoid near plane “cut opens” via depth clamping </li></ul><ul><ul><li>Fragment shader replaces color of z=0 fragments with black </li></ul></ul><ul><ul><li>In GLSL: if (gl_FragCoord.z == 0) gl_FragColor = vec4(0,0,0,1); </li></ul></ul><ul><ul><li>Alternatively, use Painter’s algorithm for objects at the near plane </li></ul></ul><ul><ul><ul><li>Last (or first) fragment at z=0 “wins” </li></ul></ul></ul><ul><li>Infinite Z-fail Shadow volumes </li></ul><ul><ul><li>See [Everett & Kilgard 2002] </li></ul></ul><ul><ul><li>Conserves depth buffer precision when eye-space infinity must be within depth range </li></ul></ul>
  53. Near Plane Depth Clamping Example without depth clamping depth clamping enabled * * simple situation because depth complexity at z=0 is a single layer
  54. Seam-free Cube Map Edges <ul><li>Cube maps have edges along each face </li></ul><ul><ul><li>Traditionally texture mapping hardware simply clamps to these seam edges </li></ul></ul><ul><li>Results in “seam” artifacts </li></ul><ul><ul><li>Particularly when level-of-detail bias is large </li></ul></ul><ul><ul><ul><li>Meaning very blurry levels </li></ul></ul></ul><ul><ul><ul><li>But seams appear sharply </li></ul></ul></ul><ul><li>Use glEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS) to mitigate these artifacts </li></ul>seam
  55. Seamless Cube Maps: Before and After <ul><li>Before: with edge seams </li></ul><ul><li>After: without </li></ul>seams
  56. Remaining OpenGL 3.2 Features <ul><li>Async objects </li></ul><ul><ul><li>Synchronization of GPU completion </li></ul></ul><ul><ul><li>Supports synchronization between multiple contexts </li></ul></ul><ul><li>Draw elements base index </li></ul><ul><ul><li>Provides a base added to all vertex indices </li></ul></ul><ul><li>Multisampled renderbuffers </li></ul><ul><ul><li>Also can query framebuffer’s sample locations </li></ul></ul>
  57. Beyond OpenGL 3.2 NVIDIA’s further contributions
  58. <ul><li>Texture arrays </li></ul><ul><ul><li>1D texture array </li></ul></ul><ul><ul><li>2D texture array </li></ul></ul><ul><ul><li>Cube map texture array </li></ul></ul><ul><li>Multisample </li></ul><ul><ul><li>2D texture multisample </li></ul></ul><ul><ul><li>2D texture array multisample </li></ul></ul>All of OpenGL’s Texture Targets <ul><li>Conventional targets </li></ul><ul><ul><li>1D texture </li></ul></ul><ul><ul><li>2D texture </li></ul></ul><ul><ul><li>3D texture </li></ul></ul><ul><li>Special addressing </li></ul><ul><ul><li>Cube map texture </li></ul></ul><ul><ul><ul><li>cube face selection </li></ul></ul></ul><ul><ul><li>Rectangle texture </li></ul></ul><ul><ul><ul><li>[0..w]x[0..h] range </li></ul></ul></ul><ul><ul><li>Texture buffer </li></ul></ul><ul><ul><ul><li>1D unfiltered buffer objects </li></ul></ul></ul>
  59. Bindless Graphics <ul><li>NVIDIA keeps building faster and faster GPUs </li></ul><ul><ul><li>But that x86 core feeding the GPU isn’t getting faster at anything near the same rate! </li></ul></ul><ul><ul><li>Makes your application more & more likely to be CPU limited, instead of GPU limited </li></ul></ul><ul><li>Bundling OpenGL state in objects helps </li></ul><ul><ul><li>But time goes on… GPUs keep getting faster… </li></ul></ul><ul><li>Eventually even binding to objects becomes a bottleneck </li></ul><ul><ul><li>Hence the desire for “bindless” graphics </li></ul></ul><ul><li>Extensions: </li></ul><ul><ul><li>NV_vertex_buffer_unified_memory (VBUM) for bindless vertex pulling </li></ul></ul><ul><ul><li>NV_shader_buffer_load (SBL) for bindless buffer loads from shaders </li></ul></ul>
  60. “Classic” OpenGL 1.0 Model Application Driver GPU command buffer GPU Video memory wide stream of commands wide interconnect <ul><li>OpenGL commands contains data directly </li></ul><ul><ul><li>Examples: immediate mode vertices, pixels to draw, downloaded texels </li></ul></ul><ul><li>Inefficient </li></ul><ul><ul><li>All data flows through the CPU </li></ul></ul><ul><ul><li>GPU can’t access the data directly from video memory </li></ul></ul>
  61. Object Bind Model of OpenGL 2.x/3.x <ul><li>OpenGL commands “name” objects to use </li></ul><ul><ul><li>Objects allow GPU to access object data (texels, vertices, pixels, constants, etc.) via fast video memory directly </li></ul></ul><ul><li>Driver must lookup and access object’s vital information </li></ul><ul><ul><li>Tends to generate lots of cache misses </li></ul></ul><ul><ul><li>Cache misses are the bane of modern, fast CPUs </li></ul></ul>Application Driver GPU command buffer GPU Video memory narrow stream of commands wide interconnect System memory expensive stream of cache misses
  62. Bindless Graphics Model of OpenGL <ul><li>OpenGL commands and shaders can use GPU addresses of buffers </li></ul><ul><ul><li>So driver doesn’t have to translate to addresses </li></ul></ul><ul><ul><li>& doesn’t take cache misses </li></ul></ul><ul><li>GPU addresses for </li></ul><ul><ul><li>Vertex buffer offsets </li></ul></ul><ul><ul><li>Constant loads from buffers within shaders </li></ul></ul>Application Driver GPU command buffer GPU Video memory narrow stream of commands wide interconnect feedback GPU address at creation time
  63. Direct State Access <ul><li>Existing OpenGL model </li></ul><ul><ul><li>Bind-to-edit , bind-to-query , bind-to-use </li></ul></ul><ul><ul><ul><li>One bind operation for all three purposes </li></ul></ul></ul><ul><ul><li>To change a GL object, you must first “bind” to it </li></ul></ul><ul><ul><ul><li>Example glBindTexture(GL_TEXTURE_2D, obj); gl Tex Parameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); </li></ul></ul></ul><ul><ul><ul><li>Bind-to-edit leads to unnecessary re-validations </li></ul></ul></ul><ul><li>NEW additional Direct State Access (DSA) approach </li></ul><ul><ul><li>Edit-by-name </li></ul></ul><ul><ul><li>To change a GL object, name the object to change </li></ul></ul><ul><ul><ul><li>Example gl Texture ParameteriEXT(obj, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); </li></ul></ul></ul><ul><li>Extension: EXT_direct_state_access </li></ul>
  64. What is the root of the problem? <ul><li>“ Selectors” </li></ul><ul><ul><li>OpenGL state that tells which state other OpenGL commands should update </li></ul></ul><ul><ul><ul><li>Think of selectors as “sticky” phantom parameters to all your matrix, texture, program, buffers, etc. commands and queries </li></ul></ul></ul><ul><ul><li>Examples of selectors </li></ul></ul><ul><ul><ul><li>glMatrixMode </li></ul></ul></ul><ul><ul><ul><li>glActiveTexture </li></ul></ul></ul><ul><ul><ul><li>glBindTexture </li></ul></ul></ul><ul><ul><ul><li>glBindProgramARB </li></ul></ul></ul><ul><ul><ul><li>glUseProgram </li></ul></ul></ul>two distinct selectors for texture commands, extra confusing
  65. Reasons to Avoid Selectors <ul><li>Direct3D has an “edit-by-name” model of operation </li></ul><ul><ul><li>Means Direct3D has no selectors </li></ul></ul><ul><ul><li>Having to manage selectors when porting Direct3D or console code to OpenGL is awkward </li></ul></ul><ul><ul><ul><li>Requires deferring updates to minimize selector and object bind changes </li></ul></ul></ul><ul><li>Layered libraries can’t count of selector state </li></ul><ul><ul><li>To be safe when updating sate controlled by selectors, such libraries must use idiom </li></ul></ul><ul><ul><ul><li>Save selector, Set selector, Update state, Restore selector </li></ul></ul></ul><ul><ul><ul><li>Bad for performance, particularly bad for dual-core drivers since queries are expensive </li></ul></ul></ul><ul><ul><li>Cg 2.2 October 2009 makes use of DSA automatically when available </li></ul></ul>
  66. Direct State Access Advantages <ul><li>Less error-prone </li></ul><ul><ul><li>Consider this code glRotatef(phi, x,y,z); </li></ul></ul><ul><ul><li>Which matrix did you change? </li></ul></ul><ul><ul><ul><li>Depends on how the matrix mode selector was last left! </li></ul></ul></ul><ul><ul><li>Instead consider the DSA version gl Matrix RotatefEXT( GL_MODELVIEW , phi, x,y,z); </li></ul></ul><ul><li>Another example </li></ul><ul><ul><li>Consider this code glActiveTexture(GL_TEXTURE3); some_function(); glBindTexture(GL_TEXTURE2D, 89); </li></ul></ul><ul><ul><li>But what if some_function calls glActiveTexture ? </li></ul></ul><ul><ul><ul><li>It might not now, but could in the future! </li></ul></ul></ul><ul><ul><li>Instead use glBind Multi TextureEXT( GL_TEXTURE3 , GL_TEXTURE_2D, 89); </li></ul></ul><ul><ul><ul><li>Problem solved! </li></ul></ul></ul>
  67. Direct State Access Advantages <ul><li>More efficient layered libraries </li></ul><ul><ul><li>Consider a library that uses OpenGL commands to create a texture object from an image file </li></ul></ul><ul><ul><ul><li>Example: loadPNGtoGLtexture(GLuint texobj, …); </li></ul></ul></ul><ul><ul><ul><li>Ideally, calling loadPNGtoGLtexture shouldn’t disturb the current bound texture </li></ul></ul></ul><ul><ul><li>Preserving the current bound texture requires a save-selector/change-state/restore-selector idiom GLint saved_current_binding; glGetIntegerv(GL_TEXTURE_BINDING_2D, &saved_current_binding); glBindTexture(GL_TEXTURE_2D, texobj); // now you can change texobj with bind-to-edit commands glBindTexture(GL_TEXTURE_2D, saved_current_binding); </li></ul></ul><ul><ul><li>But save/change/restore undermines dual-core OpenGL operation </li></ul></ul><ul><ul><ul><li>Because GL queries of the selector sync the app and driver threads </li></ul></ul></ul><ul><ul><li>DSA routines avoid disturbing selectors </li></ul></ul><ul><ul><ul><li>Cg 2.2 October 2009 is an example of such a library </li></ul></ul></ul>
  68. Latched State <ul><li>Direct State Access solves another problem </li></ul><ul><ul><li>Some OpenGL state is “latched” by subsequent commands </li></ul></ul><ul><ul><li>Think of latched state as phantom parameters to commands that come from the OpenGL state </li></ul></ul><ul><ul><ul><li>Examples: pixel store (pack/unpack) state, vertex array state </li></ul></ul></ul><ul><li>Provides new commands </li></ul><ul><ul><li>glPushClientAttribDefaultEXT command </li></ul></ul><ul><ul><ul><li>Like glPushClientAttrib but also resets affected state to default </li></ul></ul></ul><ul><ul><li>Fast and efficient </li></ul></ul>
  69. Copy Image <ul><li>Fast copies of pixels between image objects </li></ul><ul><ul><li>1D textures, 2D textures, 3D textures, cube maps, texture rectangles, 1D texture arrays, 2D texture arrays, cube map texture arrays, & render-buffers all work </li></ul></ul><ul><li>Pixel data can be 1D, 2D, or 3D </li></ul><ul><li>Best part </li></ul><ul><ul><li>Image objects can belong to distinct OpenGL rendering contexts </li></ul></ul><ul><ul><li>Even when contexts do not share objects! </li></ul></ul><ul><ul><li>Even when contexts on system’s different physical GPUs </li></ul></ul><ul><li>Extension: NV_copy_image </li></ul>
  70. Basic Copy Image Command <ul><li>Basic prototype, for within a context void glCopyImageSubDataNV( GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth ); </li></ul><ul><li>Color key: </li></ul><ul><ul><li>source arguments </li></ul></ul><ul><ul><li>destination arguments </li></ul></ul><ul><ul><li>sub-image dimensions </li></ul></ul>
  71. Texture Barrier <ul><li>Background </li></ul><ul><ul><li>Framebuffer objects allow rendering into textures </li></ul></ul><ul><ul><li>Nothing keeps you from sampling a texture you are also bound to, though the behavior is specified to be undefined </li></ul></ul><ul><li>Provides a mechanism to avoid read-after-write hazards when rendering into a bound texture </li></ul><ul><ul><li>In limited circumstances </li></ul></ul><ul><ul><ul><li>Reads (including all filtered samples) and writes are to/from disjoint pixels </li></ul></ul></ul><ul><ul><ul><li>There is only a single read and write of a pixel by a fragment shader “over” that pixel without an intervening glTextureBarrierNV() command </li></ul></ul></ul><ul><li>Extension: NV_texture_barrier </li></ul>
  72. Improved: Parameter Buffer Object <ul><li>Parameter buffer objects give shaders access to values stored in buffers </li></ul><ul><ul><li>Also called constant or uniform buffers </li></ul></ul><ul><ul><li>Supported by Cg 2.2’s BUFFER semantics </li></ul></ul><ul><li>Originally just 32-bit scalars or 32-bit 4-component vectors </li></ul><ul><ul><li>Now 1, 2, 4, 8, or 16 byte accesses allowed </li></ul></ul><ul><li>Extension: NV_parameter_buffer_object2 </li></ul>
  73. Separate Shader Objects <ul><li>Combining different GLSL shaders at once </li></ul><ul><ul><li>Needed linking </li></ul></ul><ul><li>Better to allow mixing and matching of shader objects </li></ul><ul><ul><li>Like Direct3D </li></ul></ul><ul><ul><li>Like OpenGL assembly extensions </li></ul></ul><ul><li>Extension: EXT_separate_shader_objects (SSO) </li></ul>Specular brick bump mapping Red diffuse Wobbly torus Smooth torus Different GLSL vertex shaders Different GLSL fragment shaders
  74. Separate Shader Object Binding <ul><li>Per-domain binding glUseShaderProgramEXT(GL_VERTEX_SHADER, vprog); glUseShaderProgramEXT(GL_GEOMETRY_SHADER, gprog); glUseShaderProgramEXT(GL_FRAGMENT_SHADER, fprog); </li></ul><ul><ul><li>Uses a linked program object, but only the portion of that linked program for the specified domain </li></ul></ul><ul><li>Introduces selector for glUniform calls glActiveProgramEXT(program_updated_by_glUniform); </li></ul><ul><ul><li>Better to use DSA’s selector-free glProgramUniform*EXT commands </li></ul></ul>
  75. glUseProgram Equivalence <ul><li>Question: What does the existing glUseProgram call “mean” in the context of SSO? glUseProgram(glsl_prog); </li></ul><ul><li>Answer : It is exactly equivalent to these calls: glUseShaderProgramEXT(GL_VERTEX_SHADER, glsl_prog); glUseShaderProgramEXT(GL_GEOMETRY_SHADER, glsl_prog); glUseShaderProgramEXT(GL_FRAGMENT_SHADER, glsl_prog); glActiveProgramEXT(glsl_prog); </li></ul>
  76. Convenient 1-Step Single-domain Shader Loading <ul><li>GLSL requires elaborate multi-step API for compiling/linking a shader </li></ul><ul><ul><li>Over-kill for separate shader objects </li></ul></ul><ul><ul><li>Desirable to have an API more like glProgramStringARB </li></ul></ul><ul><li>1-Step command glCreateShaderProgramEXT( GLenum domain, const char *shader_string); </li></ul><ul><li>Just a convenience function </li></ul><ul><ul><li>You don’t have to use it for SSO </li></ul></ul><ul><ul><li>You can still create separate shaders with multi-step API </li></ul></ul><ul><ul><li>Sometimes necessary for binding attributes and fragment out locations </li></ul></ul>
  77. glCreateShaderProgramEXT <ul><li>Equivalent to: </li></ul><ul><li>const GLuint shader = glCreateShader (type); </li></ul><ul><li>if (shader) { </li></ul><ul><li>const GLint len = ( GLint ) strlen(string); </li></ul><ul><li>glShaderSource (shader, 1, &string, &len); </li></ul><ul><li>glCompileShader (shader); </li></ul><ul><li>const GLuint program = glCreateProgram (); </li></ul><ul><li>if (program) { </li></ul><ul><li>GLint compiled = GL_FALSE ; </li></ul><ul><li>glGetShaderiv (shader, GL_COMPILE_STATUS , &compiled); </li></ul><ul><li>if (compiled) { </li></ul><ul><li>glAttachShader( program, shader); </li></ul><ul><li>glLinkProgram (program); </li></ul><ul><li>glDetachShader (program, shader); </li></ul><ul><li>} </li></ul><ul><li>// Possibly... </li></ul><ul><li>if ( active-user-defined-varyings-in-linked-program ) { </li></ul><ul><li>append-error-to-info-log </li></ul><ul><li>set-program-link-status-false </li></ul><ul><li>} </li></ul><ul><li>append-shader-info-log-to-program-info-log </li></ul><ul><li>} </li></ul><ul><li>glDeleteShader (shader); </li></ul><ul><li>return program; </li></ul><ul><li>} else { </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  78. Passing Varyings Between Separate Shader Objects <ul><li>Programs in separate domains should pass varyings through builtin varyings (NOT user-specified varyings) </li></ul><ul><ul><li>So instead of varying float4 my_varying; </li></ul></ul><ul><ul><li>Use a built-in such as gl_Texcoord[0] </li></ul></ul><ul><ul><li>Guarantees up-stream and down-stream domains rendezvous with the same value </li></ul></ul><ul><li>Use of user-declared varyings are undefined </li></ul><ul><li>Compiling Cg code to GLSL profiles guarantees this is the case </li></ul><ul><ul><li>Cg has semantics to indicate how varyings correspond to API resources </li></ul></ul><ul><ul><li>Example Cg declaration: float4 my_varying : TEXCOORD0; </li></ul></ul>
  79. Thoughts of OpenGL Future what direction now?
  80. Where Do OpenGL Extensions Come From? <ul><li>44% of extensions are “core” or multi-vendor </li></ul><ul><li>Lots of vendors have initiated extensions </li></ul><ul><li>Extending OpenGL is industry-wide collaboration </li></ul>EXT SGI SGIS SGIX ARB NV Others Others ATI APPLE MESA Source: (Dec 2008)
  81. What’s Driving OpenGL Modernization? Human desire for Visual Intuition and Entertainment Embarrassing Parallelism of Graphics Increasing Semiconductor Density Particularly the hardware-amenable, latency tolerant nature of rasterization Particularly interactive video games
  82. Conclusions <ul><li>NVIDIA’s OpenGL driver leads the industry </li></ul><ul><ul><li>Functional, performance, & semantic parity with Direct3D </li></ul></ul><ul><ul><li>NVIDIA provides OpenGL 3.2 now </li></ul></ul><ul><li>If past is prologue…  </li></ul><ul><ul><li>NVIDIA OpenGL extensions: where to-be-core functionality shows up first </li></ul></ul><ul><ul><ul><li>Get a head-start by using the functionality now </li></ul></ul></ul><ul><ul><li>All new GPU functionality exposed for OpenGL in first shipping NVIDIA driver </li></ul></ul>
  83. More Information <ul><li>NVIDIA OpenGL 3.2 driver </li></ul><ul><ul><li>Available now! </li></ul></ul><ul><ul><li> </li></ul></ul><ul><li>OpenGL 3.2 specification </li></ul><ul><ul><li> </li></ul></ul><ul><li>NVIDIA’s OpenGL extension registry </li></ul><ul><ul><li> </li></ul></ul><ul><li>Cg Toolkit 2.2 October 2009 </li></ul><ul><ul><li>Includes geometry shader examples shown here </li></ul></ul><ul><ul><li> cg_toolkit.html </li></ul></ul>
  84. Links to Specific Extension Specifications <ul><li>Provoking Vertex </li></ul><ul><li>Vertex Array BGRA </li></ul><ul><li>Depth Clamp </li></ul><ul><li>Texture Multisample </li></ul><ul><li>Seamless Cube Map </li></ul><ul><li>Fragment Coordinate Conventions </li></ul><ul><li>Synchronization Objects </li></ul><ul><li>Geometry Shaders </li></ul><ul><li>Bindless graphics </li></ul><ul><ul><li>Shader Buffer Load </li></ul></ul><ul><ul><li>Vertex Buffer Unified Memory </li></ul></ul><ul><li>Direct State Access </li></ul><ul><li>Separate Shader Objects </li></ul><ul><li>Copy Image </li></ul><ul><li>Texture Barrier </li></ul><ul><li>Draw Elements Base Vertex </li></ul>