我使用 OpenGL4.X。最近我阅读了 this Apple OpenGLES2 文档,其中指出使用交错属性数组可以提高 IOS 移动设备上的性能,并且是推荐的方法(而不是使用属性 block )。
对于那些不明白我意思的人,这里有一个例子:
单个属性数组中的属性 block :
float vertices[]{
//Triangle vertices:
v0x , v0y , v0z ,
v1x , v1y , v1z ,
v2x , v2y , v2z ,
//Triangle UVs:
uv0s , uv0t ,
uv1s , uv1t ,
uv2s , uv2t ,
//Triangle Normals:
n0x , n0y , n0z ,
n1x , n1y , n1z ,
n2x , n2y , n2z
}
交错属性数组:
float vertices[]{
v0x , v0y , v0z ,
uv0s , uv0t , ////vertex 1 attributes
n0x , n0y , n0z ,
v1x , v1y , v1z ,
uv1s , uv1t , ///vertex 2 attributes
n1x , n1y , n1z ,
v2x , v2y , v2z ,
uv2s , uv2t , ///vertex 3 attributes
n2x , n2y , n2z
}
所以我的问题是:在桌面 GPU 上运行的 OpenGL 是否也是如此?如果是,那么理论上性能增益有多大?
最佳答案
Is it also true for OpenGL running on desktop GPUs ?
来自 Vertex specification wiki page :
As a general rule, you should use interleaved attributes wherever possible. Obviously if you need to change certain attributes and not others, then interleaving the ones that change with those that don't is not a good idea.
how big the performance gain can theoretically be ?
我真的无法回答这个问题,但我不希望有很大的改进。唯一确定的方法是测量。
关于c++ - 在 OpenGL4.0 中使用交错属性数组提高性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14874914/