バイト最適化によってパフォーマンスがどの程度向上するか (8、32、64 の倍数など)?
サンプル構造は次のとおりです。
[StructLayout(LayoutKind.Explicit)]
public struct RenderItem
{
[FieldOffset(0)] byte[] mCoordinates = new byte[3]; //(x,y,z)
[FieldOffset(3)] short mUnitType;
}
だから私の質問は、次のようなことをすることがどれほど重要かということです:
[StructLayout(LayoutKind.Explicit)]
public struct RenderItem
{
[FieldOffset(0)] byte[] mCoordinates = new byte[3]; //(x,y,z)
[FieldOffset(4)] short mUnitType;
[FieldOffset(6)] byte[] mPadding = new byte[2]; //make total to 8 bytes
}
「サイズに合わせてスケーリングする」ものの 1 つであると確信しているため、特に、VertexBuffer オブジェクトを作成するためにこの構造が約 150,000 回使用される操作に興味があります。
//int objType[,,] 3 dimensional int with object type information stored in it
int i = 0;
RenderItem vboItems[16 * 16 * 16 * 36] //x - 16, y - 16, z - 16, 36 verticies per object
For(int x = 0; x < 16; x++)
{
For(int y = 0; y < 16; y++)
{
For(int z = 0; z < 16; z++)
{
vboItems[i++] = (x,y,z,objType[x,y,z]);
}
}
}
//Put vboItems into a VBO