Andrew Reece
01/21/2019, 11:05 PMibdknox
01/22/2019, 12:56 AMibdknox
01/22/2019, 12:57 AMibdknox
01/22/2019, 1:28 AMibdknox
01/22/2019, 1:29 AMgman
01/22/2019, 6:33 AMclass Person {
string name;
string address;
string phone;
}
not as
string[] PhoneNumbers;
string[] Names;
string[] Addresses
class Person {
int nameNdx;
int addressNdx;
int phoneNumberNdx;
};
Probably a bad example but hopefully you get my point. I'm sure systems exist to make things look more like the former but under the hood act like the latter. In fact [Unity's Entity Component System](https://unity.com/unity/features/job-system-ECS) is one such system.
But usage is still far more involved than the more obvious method.
If I'm not making sense what I'm trying to say is that organizing around perf is mostly a topic for experienced programmers.
Another maybe good example is three.js, it started with Vertex objects, each object holding 3 values. You'd make arrays of them then make Face objects and add Vertex objects to do those to make polygons. That's arguably the most obvious idea and when three.js was mostly a software renderer it worked.
But then as they added WebGL they ran into the issue that the GPU needs the data all laid out in nice parallel arrays so they have this issue where they currently have 2 paths.
Path 1, the old path, Use Vertex and Face, and then the library has to convert to a GPU friendly format anytime data is changed.
Path 2, build GPU friendly formats directly, no intermediate format.
The problem with Path 2 is for inexperienced programmers they have to deal with data as individual numbers in an array. In other words, to a specific vertex in path 1 could be as simple as
const vertex = vertices[vertexIndex]; // easy
where as the GPU friendly way is more like
const offset = vertexIndex * stride;
const x = vertices[offset + 0];
const y = vertices[offset + 1];
const z = vertices[offset + 2];
const vertex = new Vertex(x, y, z); // because you want access to vertex methods these 3 values need to be assign a type.
That looks trivial to an experienced programmer but not to a beginner.
Anyway, there are probably ways to solve that type of issue and give both perf and easy to follow code for a beginner but I haven't seen any.Scott Anderson
01/22/2019, 6:58 PMAndrew Reece
01/22/2019, 9:44 PMclass People {
string[] phoneNumbers;
string[] names;
string[] addresses;
}
which is not too dissimilar from your original layout. If you squint a bit, you can see the members as the column headers of a table called People...Andrew Reece
01/22/2019, 9:50 PMScott Anderson
01/22/2019, 10:02 PMScott Anderson
01/23/2019, 1:24 AMibdknox
01/23/2019, 7:28 AM