简体   繁体   English

如何使用FBO改善glTexImage2D性能

[英]how to to improve glTexImage2D performance using FBO

I implemented an opengl-es application running on mali-400 gpu. 我实现了在Mali-400 gpu上运行的opengl-es应用程序。 I grab the 1280x960 RGB buffer from camera and render on gpu using glTexImage2D. 我从相机抓取1280x960 RGB缓冲区,并使用glTexImage2D在gpu上渲染。

However the glTexImage2D call takes around 25 milliseconds for 1280x960 resolution frame. 但是,对于1280x960分辨率的帧,glTexImage2D调用大约需要25毫秒。 It does extra memcopy of pCameraBuffer. 它会额外复制pCameraBuffer。

1) Is there any way to improve the performance of glTexImage2D? 1)有什么方法可以改善glTexImage2D的性能吗? 2) Will FBO help? 2)FBO有帮助吗? how can I use Frame Buffer Objects to render. 如何使用帧缓冲区对象进行渲染。 I found few FBO examples, but I see that these examples pass NULL to glTexImage2d in last argument (data). 我发现了几个FBO示例,但是我看到这些示例在最后一个参数(数据)中将NULL传递给glTexImage2d。 so how can I render pCameraBuffer with FBO? 那么如何使用FBO渲染pCameraBuffer?

below is the code running for each camera frame. 以下是为每个摄像机框架运行的代码。

glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, SCENE_WIDTH, SCENE_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, pCameraBuffer);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDeleteTextures(1, &textureID);

The usual approach to this type of thing is to try and import the camera buffer directly into the graphics driver, avoiding the need for any memory allocation or copy at all. 这类事情的常用方法是尝试将相机缓冲区直接导入图形驱动程序,而根本无需进行任何内存分配或复制。 Whether this is supported depends on a lot on the platform integration, and the capabilities of the drivers in the system. 是否支持此功能在很大程度上取决于平台集成以及系统中驱动程序的功能。

For Linux systems, which is what you indicate you are using, the route is via the EGL_EXT_image_dma_buf_import extension. 对于您正在使用的Linux系统,路由是通过EGL_EXT_image_dma_buf_import扩展名。 You need a camera driver which creates a surface backed by dma_buf managed memory, and a side-channel to get the dma_buf file handle into the application running the graphics operations. 您需要一个摄像头驱动程序,该驱动程序创建一个由dma_buf受管内存支持的表面,以及一个辅助通道,以将dma_buf文件句柄放入运行图形操作的应用程序中。 You can then turn this into an EGLImage using the extension above. 然后,您可以使用上述扩展名将其转换为EGLImage。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM