1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
{$MODESWITCH ADVANCEDRECORDS}
Type
TBZVector4fType = packed array[0..3] of Single; //< Tableau aligné pour les vecteur 4D Single
TBZVector4f = record
public
class operator +(constref A, B: TBZVector4f): TBZVector4f; {$ifdef USE_VECTORCALL} vectorcall; {$endif}overload;
case Byte of
0: (V: TBZVector4fType); //< Array access
1: (X, Y, Z, W: Single); //< Legacy access²
2: (Red, Green, Blue, Alpha: Single); //< As Color components in RGBA order
3: (AsVector3f : TBZVector3f); //< As TBZVector3f
4: (ST, UV : TBZVector2f); //< As Texture Coordinates
5: (Left, Top, Right, Bottom: Single); //< As Legacy Rect
6: (TopLeft,BottomRight : TBZVector2f); //< As Bounding Rect
end;
Implementation
class operator TBZVector4f.+(constref A, B: TBZVector4f): TBZVector4f; assembler; nostackframe; register; {$ifdef USE_VECTORCALL} vectorcall; {$endif}
asm
{$ifdef USE_VECTORCALL}
Addps xmm0, xmm1
{$else}
movaps xmm0, XMMWORD PTR [A]
addps xmm0, XMMWORD PTR [B]
{$endif}
movaps [RESULT], xmm0 // Ici il faut que je vérifie mais il me semble que du coup ce n'est plus obligatoire aussi avec VECTORCALL. Le registre XMM0 est automatiquement retourné
end; |
Partager