Direct access to OpenGL texture memory

3,661 views
3,242 views

Published on

This presentation regards working with graphic applications, and in particular it deals with OpenGL's texture direct memory access.

Presentation by Rostyslav Lesovyi, Software engineer, GlobalLogic. Mobile TechTalk, Lviv, 2014.
More details - www.globallogic.com.ua/press-releases/mobile-techtalk-lviv/

Published in: Software, Technology, Art & Photos
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,661
On SlideShare
0
From Embeds
0
Number of Embeds
397
Actions
Shares
0
Downloads
39
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Direct access to OpenGL texture memory

  1. 1. CONFIDENTIAL©2013 GlobalLogic Inc. by Rostyslav Lesovyi OpenGL's texture DMA DMA stands for Direct Memory Access
  2. 2. ©2013 GlobalLogic Inc. CONFIDENTIAL
  3. 3. CONFIDENTIAL • Async texture upload • Rapid updates of texture or its parts • Texture data download Problems
  4. 4. CONFIDENTIAL • Simple download/upload • Shared OpenGL contexts • PBO (Pixel Buffer Objects) • EGLImage and GraphicBuffer Solutions
  5. 5. CONFIDENTIAL Pros: • very easy to use and understand Cons: • super slow!!! • operates in a single thread • glTexImage2D/glTexSubImage2D for upload • glReadPixels for download Simple download/upload
  6. 6. CONFIDENTIAL • create background thread • create shared OpenGL context • attach context to background thread • use glTexImage2D, glTexSubImage2D or glReadPixels What to do Shared OpenGL contexts
  7. 7. CONFIDENTIAL EGLContext context = egl.eglCreateContext(display, config, parentContext, null); EGLSurface surface = egl.eglCreatePbufferSurface(display, config, surfaceAttributes); Shared context creation: Shared OpenGL contexts
  8. 8. CONFIDENTIAL EGLContext context = egl.eglCreateContext(display, config, parentContext, null); EGLSurface surface = egl.eglCreatePbufferSurface(display, config, surfaceAttributes); Shared OpenGL contexts
  9. 9. CONFIDENTIAL Pros: • relatively easy to use • full threading support Cons: • relying on slow functions Shared OpenGL contexts More info: https://github.com/pcwalton/test-async-texture-upload
  10. 10. CONFIDENTIAL Pixel Buffer Objects
  11. 11. CONFIDENTIAL Pixel Buffer Objects Pros: • relatively easy to use • supports asynchronous upload/download Cons: • Android 4.3+ / OpenGL ES 3.0 • hard to use for two-ways texture updates • still copies from PBO to CPU and vice versa More info: http://www.songho.ca/opengl/gl_pbo.html
  12. 12. CONFIDENTIAL EGLImage and GraphicBuffer Regular PC CPU GPU CPU Memory GPU Memory Copy Mobile device, AMD APUs, etc... CPU GPU Shared Memory = Texture image data (actual pixels)
  13. 13. CONFIDENTIAL EGLImage and GraphicBuffer Pros: • direct access to texture’s pixel data • can be accessed by any thread • supported by Android 2.0.1+ Cons: • requires NDK • requires usage of ARM library More info: https://wiki.mozilla.org/Platform/GFX/Gralloc
  14. 14. CONFIDENTIAL©2013 GlobalLogic Inc. Q&A
  15. 15. CONFIDENTIAL©2013 GlobalLogic Inc. Thank you

×