qehgt
qehgt

Reputation: 2990

OpenGL ES rendering to user-space memory

I need to implement off-screen rendering to texture on an ARM device with PowerVR SGX hardware.

Everything is done (pixelbuffers and OpenGL ES 2.0 API were used). The only problem unsolved is very slow glReadPixels function.

I'm not an expert in OpenGL ES, so I'm asking community: is it possible to render textures directly into user-space memory? Or may be there is some way to get hardware address of texture's memory region? Some other technique (EGL extensions)?

I don't need an universal solution, just working one for PowerVR hardware.

Update: A little more information on 'slow function glReadPixels'. Copy 512x512 RGB texture data to CPU's memory:

In case of bigger textures, differences are bigger too.

Upvotes: 4

Views: 4740

Answers (3)

qehgt
qehgt

Reputation: 2990

Solved.

The way how to force OpenVR hardware render into user-allocated memory: http://processors.wiki.ti.com/index.php/Render_to_Texture_with_OpenGL_ES#Pixmaps

An example, how to use it: https://gforge.ti.com/gf/project/gleslayer/

After all of this I can get rendered image as faster as 5 ms.

Upvotes: 4

Justicle
Justicle

Reputation: 15183

Frame buffer objects are what you are looking for. They are supported on OpenGL ES, and on PowerVr-SGX

EDIT: Keep in mind that GPU/CPU hardware is incredibly optimized towards moving data in one direction from CPU side to GPU side. The backpath from GPU to CPU is often much slower (its just not a priority to spend hardware resources on). So what ever technique you use (eg FBO/getTexImage) you're going to run against this limit.

Upvotes: 0

crazyjul
crazyjul

Reputation: 2539

When you call opengl functions, you're queuing commands in a render queue. Those commands are executed by the GPU asynchronously. When you call glReadPixels, the cpu must wait the gpu to finish its rendering. So the call might be waiting for that draw to finish. On most hardware ( at least those I work on ), the memory is shared by the cpu and the gpu, so the read pixel should not be that slow if the rendering is done.

If you can wait the result or deferred it to the next frame, you might not see that delay anymore

Upvotes: 0

Related Questions