GTC 2009 OpenGL Gold


Published on

Michael Gold's slides presented at GPU Technology Conference (GTC) in San Jose on September 30, 2009

Published in: Technology, Art & Photos
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

GTC 2009 OpenGL Gold

  1. 1. Michael I Gold NVIDIA Corporation <ul><li>OpenGL Interoperability </li></ul>
  2. 2. What is Interoperability? <ul><li>Share memory objects between APIs or contexts within an API </li></ul><ul><li>Share within a device, or between devices </li></ul><ul><li>Implicit or explicit synchronization </li></ul>
  3. 3. Who can play? <ul><li>CUDA </li></ul><ul><li>OpenCL </li></ul><ul><li>OpenGL </li></ul><ul><li>Direct3D </li></ul>
  4. 4. CUDA Interoperability <ul><li>Import OpenGL buffer objects as CUDA device pointers </li></ul><ul><ul><li>Read or write buffer memory directly from a kernel </li></ul></ul><ul><ul><li>Implicit synchronization within a CPU thread </li></ul></ul><ul><li>Texture support coming soon </li></ul>
  5. 5. CUDA Interop: Example Application OpenGL driver CUDA driver Quadro or GeForce display Tesla or GeForce Interop fast <ul><li>Multi-card interop fastest with GL on Quadro. Transfer between cards w/o CPU intervention </li></ul><ul><li>GeForce performs indirect copy, functional but slower </li></ul>Interop faster
  6. 6. CUDA example: Initalization <ul><li>// Create a GL buffer object </li></ul><ul><li>glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer); </li></ul><ul><li>glBufferData(GL_PIXEL_UNPACK_BUFFER, buffer_size, NULL, GL_STREAM_COPY); </li></ul><ul><li>// Register the buffer object for CUDA interop </li></ul><ul><li>cuGLRegisterBufferObject(buffer); </li></ul><ul><li>cuGLSetBufferObjectMapFlags(buffer, CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD); </li></ul>
  7. 7. CUDA example: Per-frame usage <ul><li>// map the buffer, invoke a kernel to populate it, and release it back to OpenGL </li></ul><ul><li>cuGLMapBufferObjectAsync(&dptr, &size, buffer, stream); </li></ul><ul><li>call_kernel(dptr, size); </li></ul><ul><li>cuGLUnmapBufferObjectAsync(&dptr, &size, buffer, stream); </li></ul><ul><li>// Use the buffer as a pixel buffer object to populate a texture </li></ul><ul><li>glTexSubImage2D( … , NULL); </li></ul>
  8. 8. CUDA resources <ul><li>Drivers, Toolkit and SDK </li></ul><ul><ul><li>http:// </li></ul></ul><ul><li>Forums </li></ul><ul><ul><li>http:// </li></ul></ul>
  9. 9. OpenCL Interoperability <ul><li>Analogous to CUDA </li></ul><ul><ul><li>Create cl_mem from textures and buffers </li></ul></ul><ul><li>Requires explicit synchronization </li></ul>
  10. 10. OpenCL Shared Objects OpenCL 3D image object OpenGL renderbuffer OpenGL buffer OpenCL buffer object OpenGL texture 2D (or cubemap face) OpenGL texture 3D OpenCL 2D image object OpenCL 2D image object clCreateFromGLBuffer clCreateFromGLTexture2D clCreateFromGLTexture3D clCreateFromGLRenderbuffer OpenGL OpenCL
  11. 11. OpenGL Interoperability <ul><li>Copy between image objects </li></ul><ul><ul><li>3D memcpy </li></ul></ul><ul><ul><li>No format conversions </li></ul></ul><ul><li>Copy between dimensionalities </li></ul><ul><ul><li>E.g. A slice of a 3D texture and a face of a cubemap are treated equally </li></ul></ul><ul><li>Copy between GPUs </li></ul><ul><ul><li>Complements WGL_NV_gpu_affinity </li></ul></ul>
  12. 12. OpenGL Interop: Example Application OpenGL driver OpenGL driver Quadro display Quadro Interop fast <ul><li>Quadro only </li></ul><ul><li>Transfer between cards, no host copy </li></ul><ul><li>Rendering window constrained to affinity GPU </li></ul>GPU affinity Offscreen buffer
  13. 13. OpenGL Interop: Usage <ul><li>wglCopyImageSubDataNV( </li></ul><ul><li>hSrcRC, srcName, srcTarget, srcLevel, srcX, srcY, srcZ, </li></ul><ul><li>hDstRC, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, </li></ul><ul><li>width, height, depth); </li></ul>
  14. 14. OpenGL Interop: Resources <ul><li>NV_copy_image extension specification </li></ul><ul><ul><li>http:// / opengl/specs/GL_NV_copy_image.txt </li></ul></ul><ul><li>NV_gpu_affinity extension specification </li></ul><ul><ul><li>http:// / opengl/specs/WGL_NV_gpu_affinity.txt </li></ul></ul>
  15. 15. Direct3D Interoperability <ul><li>Import Direct3D buffer and image resources into OpenGL </li></ul><ul><ul><li>Vertex and Index buffers -> buffer objects </li></ul></ul><ul><ul><li>Textures and surfaces -> textures and renderbuffers </li></ul></ul><ul><li>Currently WinXP / Direct3D 9 only </li></ul><ul><li>Experimental extension </li></ul><ul><ul><li>WGL_ NVX _DX_interop </li></ul></ul>
  16. 16. Direct3D Interop: Example Application OpenGL driver DX driver Quadro or GeForce display Interop fast <ul><li>OGL can map DX buffers, not the other way </li></ul><ul><li>Single GPU only (at this time) </li></ul>