We have wrote a YUV2RGB shader in the GPU and used glTexImage2D to transfer yuv Luminance data to GPU.
the resolution of the frame is about 600*300, it cost about 40 ms to copy one frame to GPU [nexus one], why it is so slow?
we have also tested with MOTO DROID (PowerVR GPU), it only costs about 3 ms to do so.
Does it need a special setting in OpenGL ES 2.0 for Adreno200?
please help me!
This is currently very slow due to the memory copies that must be done to get data from the camera to the GPU. A fix for this is currently in development for Froyo but is not yet publicly available.
Thanks for your response.
but that's verid, if I change glTexImage2D data type to GL_RGBA, it only cost 9 ms to copy data to GPU.
so my question is why GL_LUMINANCE cost 40ms to copy the same data to GPU?
is that the driver uses RGBA format, so GL_LUMINANCE need an extra convert time?
Yes, our drivers internally only deal with RGBA and so every texture loaded is converted. I don’t think it should take so much longer to load a luminance texture compared to a RGB, but this could be a performance issue as opposed to a driver issue. If you can provide the test application we can attempt to help debug the issue for you.
Hello,
I have exactly the same issue. I am developing an AR app in which I want to use the preview images from the camera as streaming textures. My setup:
- nexus one
- camera preview with 2 preview callback buffers, resolution 800x480
- RENDERMODE_WHEN_DIRTY enabled (glSurfaceView::onDraw only executed when a new camera preview image is available)
- initial setup in glSurfaceView::onSurfaceCreate creates two 1024x1024 GL_LUMINANCE textures with glTexImage2D, setups orthographic projection, gl surface setup: setEGLConfigChooser(8, 8, 8, 8, 0, 0);
- In glSurfaceView::onDraw, a full screen 800x840 quad is rendered using glDrawArrays() with GL_VERTEX_ARRAY, GL_TEXCOORDS_ARRAY enabled and pointing to the vertex and texcoords buffers.
- After the quad is rendered the texture is updated directly from the received camera preview buffer with a glTexSubImage2D call (also in onDraw (!)) updating only 800x480 in the 1024x1024 texture (GL_LUMINANCE), so I am directly copying the Y plane from the YUV420SP (NV21) buffer. After the glTexSubImage2D the buffer is readded as preview callback buffer.
With this setup the onDraw function takes between 185-200 ms. When I disable the glDrawArrays call the onDraw function only takes 3-5ms. Also, when I disable the glTexSubImage2D and enable the glDrawArrays call it takes 3-5ms. GL calls are error checked and no errors occur. I do not fully understand what's going on. I assume that the path from glTexSubImage2D to videomemory is fast and not too buffered by the driver. Why do things get slow when the glDrawArrays call is enabled to draw and texture the quad and after that, glTexSubImage2D is called to update the texture for the next onDraw?I do not glTexSubImage2D to the texture that is bind for texturing. I switch between them, glDrawArrays using texture 0, upload to 1 and vica versa.
Is this connected to your previous post about the slow buffer access? When will the fix you mentioned for Froyo be available? I can supply a test project if needed.
Thank you.
I have tested glTexImage2D on different GPUs including Adreno 200, PowerVR530, 540, Tegra2 and OMAP, It will take too much time to do glTexImage2D while needing to do 16-bits RGB uploading from main memory to graphics memory on Adreno 200.
when will you update driver to fix this issue?
This will cause we can't use OpenGL solution on Adreno.
evrin_yu,
how does glTexImage2D perform on the VR530,540, Tegra2, OMAP and on which devices did you test? Do you get usable performance or is it the same as with the Adreno 200?
I need to create 1024 by 768 texture with 16-bit RGB on our app. on Adreno 200 (HTC Desire, HTC EVO, Incredible, Mytouch), it needs about 330ms to do glTexImage2D. on PowerVR 540 (Samsung Galaxy tab and Samsung Galaxy S), it just needs about 20ms.
I need to call glTexImage2D frequently because each frame has different content.
our app needs to support different devices including android tab and android phone. most of phone use adreno 200. Thus we can't use opengl solution to do. for other non-adreno devices, we can use opengl to improve performance.
Can you tell us when the Froyo patch will be publicly available?
Any time soon? Weeks? Months?
Thanks.