本文介绍了是glBufferSubData还是glMapBuffer更好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了更新我的统一缓冲区对象,我使用glBufferSubData.将glBufferSubDataglMapBufferglUnmapBuffer一起使用会更快吗?

In order to update my uniform buffer objects I use glBufferSubData. Is it faster to use glBufferSubData or glMapBuffer with glUnmapBuffer?

推荐答案

关于glMapBuffer的好处是,您不需要先将数据复制到数组中,然后使用glBufferSubData来填充opengl缓冲区.使用glMapBuffer,您可以将数据直接复制到内存的一部分,必要时opengl会将其提取到GPU.从我的角度来看,当您要填充将要经常更新的大缓冲区时,glMapBuffer应该会更快.同样,如何将数据复制到glMapBufferglUnmapBuffer之间的缓冲区中也很重要.

The good thing about glMapBuffer is that you dont need to copy the data first in an array and then use glBufferSubData to fill the opengl buffer. With glMapBuffer, you can copy the data directly to part of memory which opengl will fetch to GPU when it is necessary. From my point of view, there glMapBuffer should be faster when you want to fill a big buffer which is going to be updated frequently. Also, how you are copying the data into the buffer between glMapBuffer and glUnmapBuffer is also important.

如果向我们展示您正在使用的glMapBuffer代码以及数据量,那么我们可以轻松地进行判断.无论如何,最终的测量结果可以告诉您哪个更好.

If show us the code which you are using the glMapBuffer and how big is the data, then we can judge easier. Anyway, in the end measurements can show you which one is better.

更新: OpenGL Insight异步缓冲区转移章节.在本章中,glMapBufferglSubBufferData函数的implicit synchronization可能对您很有趣.

UPDATE: OpenGL Insight Asynchronous Buffer Transfer Chapter. In this chapter, the implicit synchronization of glMapBuffer and glSubBufferData functions may be interesting for you.

这篇关于是glBufferSubData还是glMapBuffer更好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 22:06