I'm trying to use gralloc to speed-up and ease texture uploads on Android. I'm have a few hick-ups, but everything is mostly great on most platforms, but there are a few that have issues. One of them is Adreno 200.
On Nexus One (QSD8250, Android 2.3.6), I'm getting Permission Error when trying to allocate memory:
E/qsd8k.gralloc(677): /dev/pmem: failed to open pmem device: Permission denied E/qsd8k.gralloc(677): /dev/pmem: failed to initialize pmem area E/qsd8k.gralloc(677): couldn't open pmem (Permission denied) E/qsd8k.gralloc(677): gralloc failed err=Permission denied W/GraphicBufferAllocator(677): alloc(2048, 2048, 5, 00000120, ...) failed -13 (Permission denied)
Could be that it's just not accessible from user space. Is there anything I can do to enable/fix it?
Another device is HTC Evo 4G (QSD8650, Android 2.3.5). I can allocate the memory and create EGLImageKHR
successfully, but then glEGLImageTargetTexture2DOES
fails with GL_INVALID_OPERATION (1282)
.
For what it's worth, this all hapens in a separate thread. I tried all HAL pixel formats (8888, 565 etc) to no success. Also android::egl_get_image_for_current_context(image);
returns 0 (probably makes sense since I pass EGL_NO_CONTEXT
when I create eglImageKHR)
.
Here is a summary of my code:
GraphicBuffer* buffer = createBuffer(width, height, format, usage, ...); buffer->lock(CPUWrite, ..); // write to it buffer->unlock(); EGLDisplay display = eglGetCurrentDisplay(); EGLint eglImgAttrs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE, EGL_NONE }; EGLContext context = EGL_NO_CONTEXT; EGLImageKHR image = eglCreateImageKHR(display, context, EGL_NATIVE_BUFFER_ANDROID, buffer->getNativeWindowBuffer(), NULL); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); int result = glGetError(); eglDestroyImageKHR(display, image); if (result != GL_NO_ERROR) { // Fall back to glTexImage2D }
Do you have any ideas about what's wrong? Should I give up on Adreno 200 support?
Thanks a lot in a advance!
I'm interested in this question as well. I'm trying to marshal some image frames in and out of OpenGL without using glReadPixels and I hit upon the same approach as you thanks to the ARM Mali guys. It's a fairly hacky way to write applications but it seems the best bet at getting any speed. It's worth noting I've tried this on both a Tegra 3 and Mali 400 device and they both allow access to gralloc via GraphicsBuffer. However I am having other issues with both of these. Has anyone managed to actually get this all working?
Not sure if this will work on Adreno 200, but maybe try the following before giving up on supportting the hardware:
1) make sure there is an EGLContext:
EGLContext context =
(EGLContext)eglGetCurrentContext()2) Use GL_TEXTURE_EXTERNAL_OES instead of GL_TEXTURE_2D