Direct access to OpenGL texture memory

  • View
    1.759

  • Download
    3

  • Category

    Software

Preview:

DESCRIPTION

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/

Citation preview

CONFIDENTIAL©2013 GlobalLogic Inc.

by Rostyslav Lesovyi

OpenGL's texture DMADMA stands for Direct Memory Access

©2013 GlobalLogic Inc. CONFIDENTIAL

CONFIDENTIAL

• Async texture upload

• Rapid updates of texture or its parts

• Texture data download

Problems

CONFIDENTIAL

• Simple download/upload

• Shared OpenGL contexts

• PBO (Pixel Buffer Objects)

• EGLImage and GraphicBuffer

Solutions

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

CONFIDENTIAL

• create background thread

• create shared OpenGL context

• attach context to background thread

• use glTexImage2D, glTexSubImage2D or glReadPixels

What to do

Shared OpenGL contexts

CONFIDENTIAL

EGLContext context =egl.eglCreateContext(display, config, parentContext, null);

EGLSurface surface =egl.eglCreatePbufferSurface(display, config, surfaceAttributes);

Shared context creation:

Shared OpenGL contexts

CONFIDENTIAL

EGLContext context =egl.eglCreateContext(display, config, parentContext, null);

EGLSurface surface =egl.eglCreatePbufferSurface(display, config, surfaceAttributes);

Shared OpenGL contexts

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

CONFIDENTIAL

Pixel Buffer Objects

CONFIDENTIAL

Pixel Buffer ObjectsPros:

• 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

CONFIDENTIAL

EGLImage and GraphicBuffer

= Texture image data (actual pixels)

CONFIDENTIAL

EGLImage and GraphicBufferPros:

• 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

CONFIDENTIAL©2013 GlobalLogic Inc.

Q&A

CONFIDENTIAL©2013 GlobalLogic Inc.

Thank you

Recommended