diff --git a/pcsx2/GS/GSVector.h b/pcsx2/GS/GSVector.h index 43ff67552c..dd52621868 100644 --- a/pcsx2/GS/GSVector.h +++ b/pcsx2/GS/GSVector.h @@ -116,7 +116,7 @@ __forceinline_odr GSVector4i::GSVector4i(const GSVector4& v, bool truncate) m = truncate ? _mm_cvttps_epi32(v) : _mm_cvtps_epi32(v); #elif defined(ARCH_ARM64) // GS thread uses default (nearest) rounding. - v4s = truncate ? vcvtq_s32_f32(v.v4s) : vcvtnq_u32_f32(v.v4s); + v4s = truncate ? vcvtq_s32_f32(v.v4s) : vreinterpretq_s32_u32(vcvtnq_u32_f32(v.v4s)); #endif } diff --git a/pcsx2/GS/GSVector4_arm64.h b/pcsx2/GS/GSVector4_arm64.h index e4759641ad..2947fc479b 100644 --- a/pcsx2/GS/GSVector4_arm64.h +++ b/pcsx2/GS/GSVector4_arm64.h @@ -703,17 +703,17 @@ public: __forceinline GSVector4 mul64(const GSVector4& v) const { - return GSVector4(vmulq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))); + return GSVector4(vreinterpretq_f32_f64(vmulq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s)))); } __forceinline GSVector4 add64(const GSVector4& v) const { - return GSVector4(vaddq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))); + return GSVector4(vreinterpretq_f32_f64(vaddq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s)))); } __forceinline GSVector4 sub64(const GSVector4& v) const { - return GSVector4(vsubq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))); + return GSVector4(vreinterpretq_f32_f64(vsubq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s)))); } __forceinline static GSVector4 f32to64(const GSVector4& v) @@ -728,10 +728,8 @@ public: __forceinline GSVector4i f64toi32(bool truncate = true) const { - const float64x2_t r = truncate ? v4s : vrndiq_f64(vreinterpretq_f64_f32(v4s)); - const s32 low = static_cast(vgetq_lane_f64(r, 0)); - const s32 high = static_cast(vgetq_lane_f64(r, 1)); - return GSVector4i(vsetq_lane_s32(high, vsetq_lane_s32(low, vdupq_n_s32(0), 0), 1)); + const int64x2_t r = truncate ? vcvtq_s64_f64(vreinterpretq_f64_f32(v4s)) : vcvtnq_s64_f64(vreinterpretq_f64_f32(v4s)); + return GSVector4i(vcombine_s32(vmovn_s64(r), vdup_n_s32(0))); } // clang-format off @@ -782,6 +780,6 @@ public: __forceinline static GSVector4 broadcast64(const void* f) { - return GSVector4(vreinterpretq_f64_f32(vld1q_dup_f64((const double*)f))); + return GSVector4(vreinterpretq_f32_f64(vld1q_dup_f64((const double*)f))); } }; diff --git a/pcsx2/GS/GSVector4i_arm64.h b/pcsx2/GS/GSVector4i_arm64.h index fdcf7d6a40..b274519ccf 100644 --- a/pcsx2/GS/GSVector4i_arm64.h +++ b/pcsx2/GS/GSVector4i_arm64.h @@ -373,7 +373,7 @@ public: __forceinline u32 minv_u32() const { - return vminvq_u32(v4s); + return vminvq_u32(vreinterpretq_u32_s32(v4s)); } __forceinline u32 maxv_s32() const @@ -383,7 +383,7 @@ public: __forceinline u32 maxv_u32() const { - return vmaxvq_u32(v4s); + return vmaxvq_u32(vreinterpretq_u32_s32(v4s)); } __forceinline static int min_i16(int a, int b) @@ -508,12 +508,12 @@ public: __forceinline GSVector4i pkl32(const GSVector4i& a) const { - return GSVector4i(vuzp1q_u32(v4s, a.v4s)); + return GSVector4i(vuzp1q_s32(v4s, a.v4s)); } __forceinline GSVector4i pku32(const GSVector4i& a) const { - return GSVector4i(vuzp2q_u32(v4s, a.v4s)); + return GSVector4i(vuzp2q_s32(v4s, a.v4s)); } __forceinline GSVector4i upl8(const GSVector4i& a) const @@ -701,7 +701,7 @@ public: __forceinline GSVector4i srl16(s32 i) const { - return GSVector4i(vreinterpretq_s32_u16(vshlq_u16(vreinterpretq_u16_s32(v4s), vdupq_n_u16(-i)))); + return GSVector4i(vreinterpretq_s32_u16(vshlq_u16(vreinterpretq_u16_s32(v4s), vdupq_n_s16(-i)))); } __forceinline GSVector4i srlv16(const GSVector4i& v) const @@ -764,7 +764,7 @@ public: __forceinline GSVector4i srav32(const GSVector4i& v) const { - return GSVector4i(vshlq_s32(vreinterpretq_u32_s32(v4s), vnegq_s32(v.v4s))); + return GSVector4i(vshlq_s32(v4s, vnegq_s32(v.v4s))); } template @@ -775,7 +775,7 @@ public: __forceinline GSVector4i sll64(s32 i) const { - return GSVector4i(vreinterpretq_s32_s64(vshlq_s64(vreinterpretq_s64_s32(v4s), vdupq_n_s16(i)))); + return GSVector4i(vreinterpretq_s32_s64(vshlq_s64(vreinterpretq_s64_s32(v4s), vdupq_n_s64(i)))); } __forceinline GSVector4i sllv64(const GSVector4i& v) const @@ -791,7 +791,7 @@ public: __forceinline GSVector4i sra64(s32 i) const { - return GSVector4i(vreinterpretq_s32_s64(vshlq_s64(vreinterpretq_s64_s32(v4s), vdupq_n_s16(-i)))); + return GSVector4i(vreinterpretq_s32_s64(vshlq_s64(vreinterpretq_s64_s32(v4s), vdupq_n_s64(-i)))); } __forceinline GSVector4i srav64(const GSVector4i& v) const @@ -808,7 +808,7 @@ public: __forceinline GSVector4i srl64(s32 i) const { - return GSVector4i(vreinterpretq_s32_u64(vshlq_u64(vreinterpretq_u64_s32(v4s), vdupq_n_u16(-i)))); + return GSVector4i(vreinterpretq_s32_u64(vshlq_u64(vreinterpretq_u64_s32(v4s), vdupq_n_s64(-i)))); } __forceinline GSVector4i srlv64(const GSVector4i& v) const @@ -858,7 +858,7 @@ public: //return GSVector4i(vreinterpretq_s32_s16(vpaddq_s16(vreinterpretq_s16_s32(v4s), vreinterpretq_s16_s32(v.v4s)))); const int16x8_t a = vreinterpretq_s16_s32(v4s); const int16x8_t b = vreinterpretq_s16_s32(v.v4s); - return GSVector4i(vqaddq_s16(vuzp1q_s16(a, b), vuzp2q_s16(a, b))); + return GSVector4i(vreinterpretq_s32_s16(vqaddq_s16(vuzp1q_s16(a, b), vuzp2q_s16(a, b)))); } __forceinline GSVector4i addus8(const GSVector4i& v) const @@ -888,7 +888,7 @@ public: __forceinline GSVector4i hsub32(const GSVector4i& v) const { - return GSVector4i(vsubq_u32(vuzp1q_u32(v4s, v.v4s), vuzp2q_u32(v4s, v.v4s))); + return GSVector4i(vsubq_s32(vuzp1q_s32(v4s, v.v4s), vuzp2q_s32(v4s, v.v4s))); } __forceinline GSVector4i subs8(const GSVector4i& v) const @@ -1029,62 +1029,62 @@ public: __forceinline GSVector4i gt8(const GSVector4i& v) const { - return GSVector4i(vreinterpretq_s32_s8(vcgtq_s8(vreinterpretq_s8_s32(v4s), vreinterpretq_s8_s32(v.v4s)))); + return GSVector4i(vreinterpretq_s32_u8(vcgtq_s8(vreinterpretq_s8_s32(v4s), vreinterpretq_s8_s32(v.v4s)))); } __forceinline GSVector4i gt16(const GSVector4i& v) const { - return GSVector4i(vreinterpretq_s32_s16(vcgtq_s16(vreinterpretq_s16_s32(v4s), vreinterpretq_s16_s32(v.v4s)))); + return GSVector4i(vreinterpretq_s32_u16(vcgtq_s16(vreinterpretq_s16_s32(v4s), vreinterpretq_s16_s32(v.v4s)))); } __forceinline GSVector4i gt32(const GSVector4i& v) const { - return GSVector4i(vcgtq_s32(v4s, v.v4s)); + return GSVector4i(vreinterpretq_s32_u32(vcgtq_s32(v4s, v.v4s))); } __forceinline GSVector4i ge8(const GSVector4i& v) const { - return GSVector4i(vreinterpretq_s32_s8(vcgeq_s8(vreinterpretq_s8_s32(v4s), vreinterpretq_s8_s32(v.v4s)))); + return GSVector4i(vreinterpretq_s32_u8(vcgeq_s8(vreinterpretq_s8_s32(v4s), vreinterpretq_s8_s32(v.v4s)))); } __forceinline GSVector4i ge16(const GSVector4i& v) const { - return GSVector4i(vreinterpretq_s32_s16(vcgeq_s16(vreinterpretq_s16_s32(v4s), vreinterpretq_s16_s32(v.v4s)))); + return GSVector4i(vreinterpretq_s32_u16(vcgeq_s16(vreinterpretq_s16_s32(v4s), vreinterpretq_s16_s32(v.v4s)))); } __forceinline GSVector4i ge32(const GSVector4i& v) const { - return GSVector4i(vcgeq_s32(v4s, v.v4s)); + return GSVector4i(vreinterpretq_s32_u32(vcgeq_s32(v4s, v.v4s))); } __forceinline GSVector4i lt8(const GSVector4i& v) const { - return GSVector4i(vreinterpretq_s32_s8(vcltq_s8(vreinterpretq_s8_s32(v4s), vreinterpretq_s8_s32(v.v4s)))); + return GSVector4i(vreinterpretq_s32_u8(vcltq_s8(vreinterpretq_s8_s32(v4s), vreinterpretq_s8_s32(v.v4s)))); } __forceinline GSVector4i lt16(const GSVector4i& v) const { - return GSVector4i(vreinterpretq_s32_s16(vcltq_s16(vreinterpretq_s16_s32(v4s), vreinterpretq_s16_s32(v.v4s)))); + return GSVector4i(vreinterpretq_s32_u16(vcltq_s16(vreinterpretq_s16_s32(v4s), vreinterpretq_s16_s32(v.v4s)))); } __forceinline GSVector4i lt32(const GSVector4i& v) const { - return GSVector4i(vcltq_s32(v4s, v.v4s)); + return GSVector4i(vreinterpretq_s32_u32(vcltq_s32(v4s, v.v4s))); } __forceinline GSVector4i le8(const GSVector4i& v) const { - return GSVector4i(vreinterpretq_s32_s8(vcleq_s8(vreinterpretq_s8_s32(v4s), vreinterpretq_s8_s32(v.v4s)))); + return GSVector4i(vreinterpretq_s32_u8(vcleq_s8(vreinterpretq_s8_s32(v4s), vreinterpretq_s8_s32(v.v4s)))); } __forceinline GSVector4i le16(const GSVector4i& v) const { - return GSVector4i(vreinterpretq_s32_s16(vcleq_s16(vreinterpretq_s16_s32(v4s), vreinterpretq_s16_s32(v.v4s)))); + return GSVector4i(vreinterpretq_s32_u16(vcleq_s16(vreinterpretq_s16_s32(v4s), vreinterpretq_s16_s32(v.v4s)))); } __forceinline GSVector4i le32(const GSVector4i& v) const { - return GSVector4i(vcleq_s32(v4s, v.v4s)); + return GSVector4i(vreinterpretq_s32_u32(vcleq_s32(v4s, v.v4s))); } @@ -1112,7 +1112,7 @@ public: __forceinline bool allfalse() const { // MSB should be clear in all 8-bit lanes. - return (vmaxvq_u32(vreinterpretq_u8_s32(v4s)) & 0x80) != 0x80; + return (vmaxvq_u8(vreinterpretq_u8_s32(v4s)) & 0x80) != 0x80; } template diff --git a/pcsx2/GS/Renderers/SW/GSDrawScanlineCodeGenerator.arm64.cpp b/pcsx2/GS/Renderers/SW/GSDrawScanlineCodeGenerator.arm64.cpp index 60b8691f48..c1602e442f 100644 --- a/pcsx2/GS/Renderers/SW/GSDrawScanlineCodeGenerator.arm64.cpp +++ b/pcsx2/GS/Renderers/SW/GSDrawScanlineCodeGenerator.arm64.cpp @@ -77,8 +77,10 @@ static const auto& _d4_f = v9; static const auto& _test = v8; static const auto& _fd = v2; -#define _local(field) MemOperand(_locals, offsetof(GSScanlineLocalData, field)) -#define _global(field) MemOperand(_globals, offsetof(GSScanlineGlobalData, field)) +// Yay, you can't offsetof with non-constant array indices in GCC +#define OFFSETOF(base, field) (reinterpret_cast(&reinterpret_cast(0)->field)) +#define _local(field) MemOperand(_locals, OFFSETOF(GSScanlineLocalData, field)) +#define _global(field) MemOperand(_globals, OFFSETOF(GSScanlineGlobalData, field)) #define armAsm (&m_emitter) GSDrawScanlineCodeGenerator::GSDrawScanlineCodeGenerator(u64 key, void* code, size_t maxsize) diff --git a/pcsx2/GS/Renderers/SW/GSSetupPrimCodeGenerator.arm64.cpp b/pcsx2/GS/Renderers/SW/GSSetupPrimCodeGenerator.arm64.cpp index 9548d060a7..f96c30cdcd 100644 --- a/pcsx2/GS/Renderers/SW/GSSetupPrimCodeGenerator.arm64.cpp +++ b/pcsx2/GS/Renderers/SW/GSSetupPrimCodeGenerator.arm64.cpp @@ -22,7 +22,9 @@ static const auto& _vscratch = v31; static constexpr const GSScanlineConstantData128B& g_const = g_const_128b; -#define _local(field) MemOperand(_locals, offsetof(GSScanlineLocalData, field)) +// Yay, you can't offsetof with non-constant array indices in GCC +#define OFFSETOF(base, field) (reinterpret_cast(&reinterpret_cast(0)->field)) +#define _local(field) MemOperand(_locals, OFFSETOF(GSScanlineLocalData, field)) #define armAsm (&m_emitter) GSSetupPrimCodeGenerator::GSSetupPrimCodeGenerator(u64 key, void* code, size_t maxsize) diff --git a/pcsx2/Gif_Unit.h b/pcsx2/Gif_Unit.h index e41300cdfe..6b6fde5d5a 100644 --- a/pcsx2/Gif_Unit.h +++ b/pcsx2/Gif_Unit.h @@ -123,7 +123,7 @@ struct Gif_Tag u64 REGS64; std::memcpy(®S64, tag.REGS, sizeof(u64)); REGS64 &= (0xFFFFFFFFFFFFFFFFULL >> (64 - nRegs * 4)); - uint8x16_t vregs = vsetq_lane_u64(REGS64, vdupq_n_u64(0), 0); + uint8x16_t vregs = vreinterpretq_u8_u64(vsetq_lane_u64(REGS64, vdupq_n_u64(0), 0)); // get upper nibbles, interleave with lower nibbles, clear upper bits from low nibbles vregs = vandq_u8(vzip1q_u8(vregs, vshrq_n_u8(vregs, 4)), vdupq_n_u8(0x0F)); diff --git a/pcsx2/ImGui/ImGuiFullscreen.cpp b/pcsx2/ImGui/ImGuiFullscreen.cpp index e7efd3ce30..321571e0dc 100644 --- a/pcsx2/ImGui/ImGuiFullscreen.cpp +++ b/pcsx2/ImGui/ImGuiFullscreen.cpp @@ -2717,7 +2717,7 @@ void ImGuiFullscreen::DrawInputDialog() ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(10.0f)); - static auto input_callback = [](ImGuiInputTextCallbackData* data) -> int { + static const ImGuiInputTextCallback input_callback = [](ImGuiInputTextCallbackData* data) -> int { InputFilterType* filter_type = static_cast(data->UserData); if (data->EventFlag == ImGuiInputTextFlags_CallbackCharFilter) {