0
struct{
Vector3* centers;
float* radii;
float* colors;
unsigned int size;
}Spheres;
struct Sphere{
Vector3 center;
float radius;
float color;
};
struct{
struct Sphere* spheres;
unsigned int size;
}Spheres;
使用示例
void spheres_process(){
int i;
for(i = 0; i < Spheres.size; ++i){
// do something with this sphere
}
}
我認爲第二種情況下具有更好的空間局部性,因爲所有的數據是交錯的,應在同一時間被加載到緩存中。在這兩種情況下,我將同時處理所有領域。任何輸入?
目標架構是x86,我正在使用GCC 4.5.0。你還喜歡其他什麼細節? – ytrp 2010-11-27 20:11:55