我正在使用一个库,它为我提供了必须传输到屏幕的帧。我分配一个缓冲区,这个库直接写入这个缓冲区。当需要时,我必须将该缓冲区的指定部分传输到屏幕。我使用 Qt 和 OpenGL/ES 绘画引擎进行渲染。
问题是:传输到屏幕的最快方法是什么?我当前正在使用接受数据指针的构造函数将缓冲区加载到 QImage 中。这应该避免任何复制。然后,我使用 QPainter
的 drawImage()
方法将正确的区域传输到屏幕上。我猜这个方法将该区域的副本加载到 GPU 内存,然后使用 OpenGL 纹理传输到屏幕。
是否可以避免此副本以加快进程?例如,是否可以直接在 OpenGL 纹理中绘制,这样我就不必传输到 GPU?我读到了像素缓冲区对象。这可能是一个解决方案吗?我可以为此目的使用QGLFramebufferObject
吗?
I'm using a library which provides me frames I have to blit to the screen. I allocate a buffer, and this library writes directly into this buffer. When I'm required, I have to blit a specified part of this buffer to the screen. I'm rendering using Qt with the OpenGL/ES paint engine.
Question is: what is the fastest way to blit to the screen? I'm currently loading the buffer in a QImage
using the constructor that accepts a pointer to data. This should avoid any copy. Then, I use the drawImage()
method of the QPainter
to blit to the screen the correct area. I guess this method loads a copy of the area to the GPU memory and then blits to the screen using an OpenGL texture.
Would it be possible to avoid this copy to speed up the process? Would it be possible for instance to draw directly in a OpenGL texture so that I don't have to transfer to the GPU? I read of pixel buffer objects. Might that be a solution? May I use for this purpose a QGLFramebufferObject
?
发布评论
评论(1)
最终,您必须写入 GPU,您所能做的就是最大程度地减少不必要的副本数量以及从 RGBA 到 BGRA 的任何 CPU 内转换的数量。
我将从 QImage 和 QPainter 开始,看看图形速度是否是开始优化之前的限制步骤。
看看 此链接。
请注意,许多一般 OpenGL 建议不适用于 opengl-ES,最好将 ES 视为与 OpenGL 完全独立的概念。
Ultimately you have to write to the GPU, all you can do is minimise the number of unnecessary copies and any in-CPU conversions from say RGBA to BGRA.
I would start with
QImage
and QPainter and see if the graphics speed is the limiting step before starting to optimise.Take a look at this link.
Note that a lot of general OpenGL advice does NOT apply to opengl-ES, it's best to think of ES as a totally separate concept to OpenGL.