Loongarch64 build fixes

This commit is contained in:
Henrik Rydgård
2026-05-25 15:41:24 +02:00
parent 8b6951c803
commit 250abe0d56
3 changed files with 11 additions and 8 deletions
+8 -5
View File
@@ -814,6 +814,7 @@ struct Mat4F32 {
// The last two loads overlap.
static Mat4F32 Load4x3(const float *m) {
Mat4F32 result;
constexpr int kOneF32Bits = 0x3F800000;
__m128 mask1110 = (__m128)__lsx_vbsrl_v(__lsx_vldi(0b11111111), 4);
result.col0 = (__m128)__lsx_vand_v((__m128i)__lsx_vld(m, 0), (__m128i)mask1110);
result.col1 = (__m128)__lsx_vand_v((__m128i)__lsx_vld(m + 3, 0), (__m128i)mask1110);
@@ -822,7 +823,7 @@ struct Mat4F32 {
// Shuffle to get [m[9], m[10], m[11], x] then mask and add 1.0f to lane 3
lastCol = (__m128)__lsx_vshuf4i_w((__m128i)lastCol, 0b11111001); // [1, 2, 3, 3]
result.col3 = (__m128)__lsx_vand_v((__m128i)lastCol, (__m128i)mask1110);
result.col3 = (__m128)__lsx_vfadd_s(result.col3, (__m128)__lsx_vinsgr2vr_w(__lsx_vldi(0), *(int *)&(float){1.0f}, 3));
result.col3 = (__m128)__lsx_vfadd_s(result.col3, (__m128)__lsx_vinsgr2vr_w(__lsx_vldi(0), kOneF32Bits, 3));
return result;
}
@@ -977,9 +978,10 @@ struct Vec4F32 {
}
static Vec4F32 LoadF24x3_One(const uint32_t *src) {
constexpr int kOneF32Bits = 0x3F800000;
__m128i value = __lsx_vslli_w(__lsx_vld(src, 0), 8);
// Set lane 3 to 1.0f
value = __lsx_vinsgr2vr_w(value, *(int *)&(float){1.0f}, 3);
value = __lsx_vinsgr2vr_w(value, kOneF32Bits, 3);
return Vec4F32{ (__m128)value };
}
@@ -1044,7 +1046,8 @@ struct Vec4F32 {
}
Vec4F32 WithLane3One() const {
return Vec4F32{ (__m128)__lsx_vinsgr2vr_w((__m128i)v, *(int *)&(float){1.0f}, 3) };
constexpr int kOneF32Bits = 0x3F800000;
return Vec4F32{ (__m128)__lsx_vinsgr2vr_w((__m128i)v, kOneF32Bits, 3) };
}
Vec4S32 CompareEq(Vec4F32 other) const { return Vec4S32{ (__m128i)__lsx_vfcmp_ceq_s(v, other.v) }; }
@@ -1109,12 +1112,12 @@ inline void TranslateAndScaleInplace(Mat4F32 &m, Vec4F32 scale, Vec4F32 translat
}
inline bool AnyZeroSignBit(Vec4S32 value) {
int mask = __lsx_vmskltz_w(value.v);
int mask = __lsx_vpickve2gr_w(__lsx_vmskltz_w(value.v), 0);
return mask != 0xF;
}
inline bool AnyZeroSignBit(Vec4F32 value) {
int mask = __lsx_vmskltz_w((__m128i)value.v);
int mask = __lsx_vpickve2gr_w(__lsx_vmskltz_w((__m128i)value.v), 0);
return mask != 0xF;
}
+2 -2
View File
@@ -527,7 +527,7 @@ static bool TestBoundingBoxFast(const float *worldViewProj, const void *vdata, i
__m128 posXY = (__m128)__lsx_vshuf4i_w(clippos, 0b01010000); // [x, x, y, y]
__m128 posW = (__m128)__lsx_vshuf4i_w(clippos, 0b11111111); // [w, w, w, w]
__m128 planeDist = (__m128)__lsx_vfmadd_s(planesMul, posXY, posW);
inside = (__m128)__lsx_vor_v(inside, (__m128)__lsx_vfcmp_cle_s((__m128)__lsx_vreplfr2vr_s(0.0f), planeDist));
inside = (__m128)__lsx_vor_v((__m128i)inside, (__m128i)__lsx_vfcmp_cle_s((__m128)__lsx_vreplfr2vr_s(0.0f), planeDist));
}
// Check if all 4 lanes are set
__m128i mask = (__m128i)__lsx_vseqi_w((__m128i)inside, 0);
@@ -578,7 +578,7 @@ bool DrawEngineCommon::TestBoundingBoxFast(const float *worldViewProj, const voi
// Check for weird scaling that can make graphics extend beyond the viewport.
// NOTE: These checks are not bullet proof.
float mtx[16];
if (vpXCenter != 2048.0f || vpYCenter != 2048.0f || vpXScale < ((scissorX2 + 1) >> 1) && vpYScale < ((scissorY2 + 1) >> 1)) {
if (vpXCenter != 2048.0f || vpYCenter != 2048.0f || vpXScale < ((scissorX2 + 1) >> 1) || vpYScale < ((scissorY2 + 1) >> 1)) {
// Note that the PSP does not clip against the viewport.
const Vec2f baseOffset = Vec2f(gstate.getOffsetX(), gstate.getOffsetY());
// Region1 (rate) is used as an X1/Y1 here, matching PSP behavior.
+1 -1
View File
@@ -1152,7 +1152,7 @@ void DrawTriangleSlice(
int32x4_t sec = vsetq_lane_s32(0, sec_color[i].ivec, 3);
prim_color[i].ivec = vaddq_s32(prim_color[i].ivec, sec);
#else
prim_color[i] += Vec4<int>(sec_color[i], 0);
prim_color[i] = Vec4<int>(sec_color[i], 0);
#endif
}
}