我注意到随着缓冲区大小的增加,在VBO中更新少量顶点的速度非常慢。 例如,当我更新时,例如512 * 512缓冲区中的2个垂直速度要慢得多,然而当我更新整个256 * 256缓冲区时,尽管更新的数据量完全相反。 这是glBufferSubData的正常行为吗?
这是我分配缓冲区的方式:
glBufferData(GL_ARRAY_BUFFER, sizeof(uiMapView::vertex)*(size + 1)*(size + 1), m_verts, GL_DYNAMIC_DRAW);这是我更新它的方式:
glBufferSubData(GL_ARRAY_BUFFER, sizeof(uiMapView::vertex)*iMinId, sizeof(uiMapView::vertex)*(iMaxId-iMinId), (&m_verts[iMinId]));I've noticed that updating a small amount of vertices in VBO goes very slow as buffer size grows. For example, when I update, say, 2 verts in a 512*512 buffer is much slower then when I update the whole 256*256 buffer despite the amounts of data updated are quite opposite. Is this a normal behavior for glBufferSubData?
This is how I allocate the buffer:
glBufferData(GL_ARRAY_BUFFER, sizeof(uiMapView::vertex)*(size + 1)*(size + 1), m_verts, GL_DYNAMIC_DRAW);This is how I update it:
glBufferSubData(GL_ARRAY_BUFFER, sizeof(uiMapView::vertex)*iMinId, sizeof(uiMapView::vertex)*(iMaxId-iMinId), (&m_verts[iMinId]));最满意答案
那么,我对我的解决方案做了更多的研究,发现VBO的更新并不是真正的瓶颈。 减少我的程序的原因是对数据进行的计算量,这显然是最大的影响。
所以,实际上,正确的anser是: 不,这不是glBufferSubData的正常行为 。 缓冲区大小不会对glBufferSubData性能产生如此巨大的影响。
Well, I made some more research on my solution and found out that VBO updating wasn't really a bottleneck. The reason of slowing my program down was an amount of calculations made with the data, wich obviously made the biggest impact.
So, actually, the right anser is: no, this is not a normal behaviour for glBufferSubData. The buffer size doesn't make such a great impact on glBufferSubData performance.
更多推荐
发布评论