a [3}慢于a.x; a.z; a.z [英] a[3} slower than a.x; a.z; a.z
问题描述
通过.x .y .z成员定义顶点结构是否更快呢
[3]数组?
-
-Gernot
int main(int argc,char ** argv){printf
("%silto%c%cf%cgl%ssic %ccom%c"," ma",58,''g'',64," ba",46,10);}
________________________________________
正在寻找一款好游戏?亲自动手吧!
GLBasic - 你可以这样做
www.GLBasic .com
>通过.x .y .z成员定义顶点结构更快,而不是[3]数组的吗?
如果你不是使用常量索引到数组中。但.x .y .z可能更具可读性。
Niels Dybdahl
" Niels Dybdahl" < nd*@fjern.detteesko-graphics.com>在消息中写道
news:41 *********************** @ news.dk.uu.net ...用.x .y .z成员定义顶点结构代替[3]数组是否更快?
如果您使用常量索引到数组中,则不会。但.x .y .z可能更具可读性。
Niels Dybdahl
使用数组。它允许您使用矩阵
操作来应用转换。
通过常量索引和成员访问之间的性能差别不大。
Catalin
>
Gernot Frisch发布:
用.x .y .z成员定义顶点结构是否更快?[/ 3]数组?
int blah [3];
struct Blah
{
int x;
int y;
int z;
}等等;
只有我能理解的差异:
实现可能*不*在数组元素之间放置填充,而它可以*在结构元素之间放置填充。
(之前和之前)有人说它...是的我确实意识到无论如何都不会在int之间填充
!:-P)
- JKop
Is it faster to define a vertex structure by .x .y .z members instead
of [3] array?
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, ''g'', 64, "ba", 46, 10);}
________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
> Is it faster to define a vertex structure by .x .y .z members insteadof [3] array?
Not if you use constants for indexing into the array. But .x .y .z might be
more readable.
Niels Dybdahl
"Niels Dybdahl" <nd*@fjern.detteesko-graphics.com> wrote in message
news:41***********************@news.dk.uu.net...Is it faster to define a vertex structure by .x .y .z members instead
of [3] array?
Not if you use constants for indexing into the array. But .x .y .z might
be
more readable.
Niels Dybdahl
Use the arrays. It allows you to apply transformations using matrix
operations. There shouldn''t be much difference of performance between
indexing through constants and member access.
Catalin
Gernot Frisch posted:
Is it faster to define a vertex structure by .x .y .z members instead
of [3] array?
int blah[3];
struct Blah
{
int x;
int y;
int z;
} blah;
Only difference I can fathom:
The implementation may *not* put padding between array elements, while it
*may* put padding between structure elements.
(And before some-one says it... YES I do realize that there wouldn''t be
padding between "int"s in anyway! :-P)
-JKop
这篇关于a [3}慢于a.x; a.z; a.z的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!