[Semi OT] Language for Game Development talk
po via Digitalmars-d
digitalmars-d at puremagic.com
Wed Oct 1 14:30:38 PDT 2014
> Perhaps a (part of) language more fit/helpful/nice for that
> purpose/use can be invented.
>
> Bye,
> bearophile
It isn't as hard as he pretends to write SoA code in C++. In
fact it is possible to abstract the underlying data you are
operating on, and replace it with vector type
Example resembling his butt ugly code: operates only on 1 float
at a time
struct Vec2{
float x,y;
};
void Add2(Vec2* points, int howMany){
for(int i = 0;i<howMany;++i){
points[i].x += 2.0f;
points[i].x += 2.0f;
}
}
How I would do it, uses AVX256:
template<class T>
struct Vec2{
T x,y;
};
typedef Vec2<float8> vec2_8f;
//float8 is a wrapper around AVX256 8 wide float type that
behaves exactly like a //normal float but is actually 8 floats.
void Add2(range<vec2_8f> points){
for(auto& p:points){
p += 2.0f;
}
}
C++ can abstract away the fact that float8 is actually
implemented using a bunch of AVX intrinsics. Using his approach
he'd be manually writing intrinsics until the cows came home.
More information about the Digitalmars-d
mailing list