什么让glBufferSubData缓冲大缓冲区?(What makes glBufferSubData slow on big buffer?)

编程入门 行业动态 更新时间:2024-10-22 18:30:10
什么让glBufferSubData缓冲大缓冲区?(What makes glBufferSubData slow on big buffer?)

我注意到随着缓冲区大小的增加,在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.

更多推荐

本文发布于:2023-07-24 20:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1250556.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓冲区   glBufferSubData   slow   buffer   big

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!