ptitSeb
Serial Porter
In the port of Jedi Knight II, I'm trying to get a few more fps, and converting some of the vector math code to Neon. The vector code if this engine is based on float[3], not 4, and because it's deep inside the engine, I cannot really change that without rewriting a large part of the game, wich I don't want to do.
I used code from here:https://code.google.com/p/math-neon/n abd tried to addapt it, but it just don't work s and I fail to see why
#ifdef NEON
inline vec_t DotProduct( const vec3_t v1, const vec3_t v2 ) {
asm volatile (
"vld1.32 {d2}, [%0] \n\t" //d2={x0,y0}
"flds s6, [%0, #8] \n\t" //d3[0]={z0}
"vld1.32 {d4}, [%1] \n\t" //d4={x1,y1}
"flds s10, [%1, #8] \n\t" //d5[0]={z1}
"vmul.f32 d0, d2, d4 \n\t" //d0= d2*d4
"vpadd.f32 d0, d0, d0 \n\t" //d0 = d[0] + d[1]
"vmla.f32 d0, d3, d5 \n\t" //d0 = d0 + d3*d5
"vmov.f32 r0, s0 \n\t" // softfp
:: "r"(v1), "r"(v2)
: "d0","d1","d2","d3","d4","d5"
);
}
#else
inline vec_t DotProduct( const vec3_t v1, const vec3_t v2 ) {
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
}
#endif
vec_t is float, and vec3_t is float[3]
I guess that with softfp you cannot just return a float using r0, but I haven't see how to return value other than using r0 . gcc inline assembler is new for me.
Any advice?
I used code from here:https://code.google.com/p/math-neon/n abd tried to addapt it, but it just don't work s and I fail to see why
#ifdef NEON
inline vec_t DotProduct( const vec3_t v1, const vec3_t v2 ) {
asm volatile (
"vld1.32 {d2}, [%0] \n\t" //d2={x0,y0}
"flds s6, [%0, #8] \n\t" //d3[0]={z0}
"vld1.32 {d4}, [%1] \n\t" //d4={x1,y1}
"flds s10, [%1, #8] \n\t" //d5[0]={z1}
"vmul.f32 d0, d2, d4 \n\t" //d0= d2*d4
"vpadd.f32 d0, d0, d0 \n\t" //d0 = d[0] + d[1]
"vmla.f32 d0, d3, d5 \n\t" //d0 = d0 + d3*d5
"vmov.f32 r0, s0 \n\t" // softfp
:: "r"(v1), "r"(v2)
: "d0","d1","d2","d3","d4","d5"
);
}
#else
inline vec_t DotProduct( const vec3_t v1, const vec3_t v2 ) {
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
}
#endif
vec_t is float, and vec3_t is float[3]
I guess that with softfp you cannot just return a float using r0, but I haven't see how to return value other than using r0 . gcc inline assembler is new for me.
Any advice?
Last edited by a moderator: