Skip to content

Commit

Permalink
Common: Add Vector4i xyxy(Vector2i)
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jan 7, 2025
1 parent 1063c3d commit 9bc5ffe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/common/gsvector_neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -2346,6 +2346,8 @@ class alignas(16) GSVector4i
return GSVector4i(vcombine_s32(xy.v2s, zw.v2s));
}

ALWAYS_INLINE static GSVector4i xyxy(const GSVector2i& xyzw) { return GSVector4i(vcombine_s32(xyzw.v2s, xyzw.v2s)); }

ALWAYS_INLINE GSVector2i xy() const { return GSVector2i(vget_low_s32(v4s)); }

ALWAYS_INLINE GSVector2i zw() const { return GSVector2i(vget_high_s32(v4s)); }
Expand Down Expand Up @@ -3153,6 +3155,8 @@ class alignas(16) GSVector4
return GSVector4(vcombine_f32(l.v2s, h.v2s));
}

ALWAYS_INLINE static GSVector4 xyxy(const GSVector2& l) { return GSVector4(vcombine_f32(l.v2s, l.v2s)); }

#define VECTOR4_SHUFFLE_4(xs, xn, ys, yn, zs, zn, ws, wn) \
ALWAYS_INLINE GSVector4 xs##ys##zs##ws() const \
{ \
Expand Down
4 changes: 4 additions & 0 deletions src/common/gsvector_nosimd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,8 @@ class alignas(16) GSVector4i
return GSVector4i(xy.x, xy.y, zw.x, zw.y);
}

ALWAYS_INLINE static GSVector4i xyxy(const GSVector2i& xyzw) { return GSVector4i(xyzw.x, xyzw.y, xyzw.x, xyzw.y); }

ALWAYS_INLINE GSVector2i xy() const { return GSVector2i(x, y); }
ALWAYS_INLINE GSVector2i zw() const { return GSVector2i(z, w); }

Expand Down Expand Up @@ -2320,6 +2322,8 @@ class alignas(16) GSVector4

ALWAYS_INLINE static GSVector4 xyxy(const GSVector2& l, const GSVector2& h) { return GSVector4(l.x, l.y, h.x, h.y); }

ALWAYS_INLINE static GSVector4 xyxy(const GSVector2& l) { return GSVector4(l.x, l.y, l.x, l.y); }

#define VECTOR4_SHUFFLE_4(xs, xn, ys, yn, zs, zn, ws, wn) \
ALWAYS_INLINE GSVector4 xs##ys##zs##ws() const { return GSVector4(F32[xn], F32[yn], F32[zn], F32[wn]); }

Expand Down
10 changes: 10 additions & 0 deletions src/common/gsvector_sse.h
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,11 @@ class alignas(16) GSVector4i

ALWAYS_INLINE GSVector4i xyxy(const GSVector4i& v) const { return upl64(v); }

ALWAYS_INLINE static GSVector4i xyxy(const GSVector2i& xyzw)
{
return GSVector4i(_mm_unpacklo_epi64(xyzw.m, xyzw.m));
}

ALWAYS_INLINE static GSVector4i xyxy(const GSVector2i& xy, const GSVector2i& zw)
{
return GSVector4i(_mm_unpacklo_epi64(xy.m, zw.m));
Expand Down Expand Up @@ -2421,6 +2426,11 @@ class alignas(16) GSVector4
return GSVector4(_mm_movelh_ps(l.m, h.m));
}

ALWAYS_INLINE static GSVector4 xyxy(const GSVector2& l)
{
return GSVector4(_mm_movelh_ps(l.m, l.m));
}

#define VECTOR4_SHUFFLE_4(xs, xn, ys, yn, zs, zn, ws, wn) \
ALWAYS_INLINE GSVector4 xs##ys##zs##ws() const \
{ \
Expand Down

0 comments on commit 9bc5ffe

Please # to comment.