Jump to content
  • Advertisement
Sign in to follow this  

__m128 / float32x4_t / float vector return arguments

This topic is 2593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, question from the friend of mine:

Is there any possibility to modify AS calling stubs to allow proper handling of '__m128 / float32x4_t / float vector' return argument ?

__m128 SomeFoo() { __m128 r; return r; }

AS_REG_OBJECT2("__m128", __m128, sizeof(__m128), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA)
as->RegisterObjectBehaviour("__m128", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(__m128_DefaultConstructor), asCALL_CDECL_OBJLAST);
as->RegisterObjectBehaviour("__m128", asBEHAVE_CONSTRUCT, "void f(const __m128 &in)", asFUNCTION(__m128_CopyConstructor), asCALL_CDECL_OBJLAST);

and now I have two functions registered to as
__m128 foo();
void bar(__m128 v);
and call:

but at bar i get total crap -- bar expects arg0 in xmm0 but gets it on the stack (foo returns arg by stack not in xmm0 - so this part is ok on x86)

on ARM (float32x4_t maps to NEON registers)
there is a crap with both returning and setting as arg.

For now I didnt tested this for PPC (ps3 cell, xbox360 xenos) but probably there will be also crap.

I have a bunch of functions that i need to register to AS but they all return float vector types, and i want to avoid production of tons of stubs just to convert return types to structs."

Share this post

Link to post
Share on other sites
The possibility exists. It requires implementing support for this type in the native calling convention code. First of all, AngelScript would need to know that the type is actually a float vector, so a flag like asOBJ_APP_FLOATVECTOR needs to be introduced. Then the code in the as_callfunc_???.cpp modules needs to be updated to properly handle this type.

Share this post

Link to post
Share on other sites
I recommend taking a look at the autowrapper add-on. They ought to work even with the __m128 type, and would avoid having to implement the wrapper functions by hand.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!