From 01e505ec8b47f1fdf77dcc78b40d70f95ca57b29 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 1 Oct 2023 14:12:25 +1000 Subject: [PATCH] Common: Add intrin.h --- src/common/CMakeLists.txt | 1 + src/common/bitutils.h | 126 +++++++++++++++++++++++++++++- src/common/common.vcxproj | 1 + src/common/common.vcxproj.filters | 1 + src/common/intrin.h | 26 ++++++ src/common/types.h | 124 ----------------------------- src/core/analog_controller.cpp | 3 +- src/core/analog_joystick.cpp | 3 +- src/core/cdrom.cpp | 10 +-- src/core/cpu_types.h | 3 +- src/core/digital_controller.cpp | 7 +- src/core/gpu_sw.cpp | 19 ++--- src/core/gpu_types.h | 3 +- src/core/imgui_overlays.cpp | 17 +--- src/core/memory_card.cpp | 3 +- src/core/memory_card_image.cpp | 13 ++- src/core/negcon.cpp | 21 ++--- src/core/pad.cpp | 3 +- src/core/sio.cpp | 13 ++- src/core/spu.cpp | 3 +- src/core/texture_replacements.cpp | 11 ++- src/util/audio_stream.cpp | 24 ++---- src/util/cd_image.h | 1 + src/util/d3d11_device.cpp | 1 + src/util/gpu_texture.cpp | 1 + src/util/shadergen.cpp | 3 +- 26 files changed, 235 insertions(+), 206 deletions(-) create mode 100644 src/common/intrin.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index d8b255a40..19dc223ed 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -19,6 +19,7 @@ add_library(common file_system.h image.cpp image.h + intrin.h hash_combine.h heap_array.h heterogeneous_containers.h diff --git a/src/common/bitutils.h b/src/common/bitutils.h index b7f96a395..3461e06e5 100644 --- a/src/common/bitutils.h +++ b/src/common/bitutils.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once @@ -8,6 +8,130 @@ #include #endif +// Zero-extending helper +template +ALWAYS_INLINE constexpr TReturn ZeroExtend(TValue value) +{ + return static_cast(static_cast::type>( + static_cast::type>(value))); +} +// Sign-extending helper +template +ALWAYS_INLINE constexpr TReturn SignExtend(TValue value) +{ + return static_cast( + static_cast::type>(static_cast::type>(value))); +} + +// Type-specific helpers +template +ALWAYS_INLINE constexpr u16 ZeroExtend16(TValue value) +{ + return ZeroExtend(value); +} +template +ALWAYS_INLINE constexpr u32 ZeroExtend32(TValue value) +{ + return ZeroExtend(value); +} +template +ALWAYS_INLINE constexpr u64 ZeroExtend64(TValue value) +{ + return ZeroExtend(value); +} +template +ALWAYS_INLINE constexpr u16 SignExtend16(TValue value) +{ + return SignExtend(value); +} +template +ALWAYS_INLINE constexpr u32 SignExtend32(TValue value) +{ + return SignExtend(value); +} +template +ALWAYS_INLINE constexpr u64 SignExtend64(TValue value) +{ + return SignExtend(value); +} +template +ALWAYS_INLINE constexpr u8 Truncate8(TValue value) +{ + return static_cast(static_cast::type>(value)); +} +template +ALWAYS_INLINE constexpr u16 Truncate16(TValue value) +{ + return static_cast(static_cast::type>(value)); +} +template +ALWAYS_INLINE constexpr u32 Truncate32(TValue value) +{ + return static_cast(static_cast::type>(value)); +} + +// BCD helpers +ALWAYS_INLINE constexpr u8 BinaryToBCD(u8 value) +{ + return ((value / 10) << 4) + (value % 10); +} +ALWAYS_INLINE constexpr u8 PackedBCDToBinary(u8 value) +{ + return ((value >> 4) * 10) + (value % 16); +} +ALWAYS_INLINE constexpr u8 IsValidBCDDigit(u8 digit) +{ + return (digit <= 9); +} +ALWAYS_INLINE constexpr u8 IsValidPackedBCD(u8 value) +{ + return IsValidBCDDigit(value & 0x0F) && IsValidBCDDigit(value >> 4); +} + +// Boolean to integer +ALWAYS_INLINE constexpr u8 BoolToUInt8(bool value) +{ + return static_cast(value); +} +ALWAYS_INLINE constexpr u16 BoolToUInt16(bool value) +{ + return static_cast(value); +} +ALWAYS_INLINE constexpr u32 BoolToUInt32(bool value) +{ + return static_cast(value); +} +ALWAYS_INLINE constexpr u64 BoolToUInt64(bool value) +{ + return static_cast(value); +} + +// Integer to boolean +template +ALWAYS_INLINE constexpr bool ConvertToBool(TValue value) +{ + return static_cast(value); +} + +// Unsafe integer to boolean +template +ALWAYS_INLINE bool ConvertToBoolUnchecked(TValue value) +{ + // static_assert(sizeof(uint8) == sizeof(bool)); + bool ret; + std::memcpy(&ret, &value, sizeof(bool)); + return ret; +} + +// Generic sign extension +template +ALWAYS_INLINE constexpr T SignExtendN(T value) +{ + // http://graphics.stanford.edu/~seander/bithacks.html#VariableSignExtend + constexpr int shift = 8 * sizeof(T) - NBITS; + return static_cast((static_cast>(value) << shift) >> shift); +} + /// Returns the number of zero bits before the first set bit, going MSB->LSB. template ALWAYS_INLINE unsigned CountLeadingZeros(T value) diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 1d7fee153..31b954b27 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -20,6 +20,7 @@ + diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters index 166b733f3..7f7a16267 100644 --- a/src/common/common.vcxproj.filters +++ b/src/common/common.vcxproj.filters @@ -43,6 +43,7 @@ + diff --git a/src/common/intrin.h b/src/common/intrin.h new file mode 100644 index 000000000..61595d297 --- /dev/null +++ b/src/common/intrin.h @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin +// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) + +// Includes appropriate intrinsic header based on platform. + +#pragma once + +#include "types.h" + +#if defined(CPU_ARCH_X86) || defined(CPU_ARCH_X64) +#define CPU_ARCH_SSE 1 +#include +#elif defined(CPU_ARCH_ARM64) +#define CPU_ARCH_NEON 1 +#ifdef _MSC_VER +#include +#else +#include +#endif +#endif + +#ifdef __APPLE__ +#include // alloca +#else +#include // alloca +#endif diff --git a/src/common/types.h b/src/common/types.h index 9a12b0b6e..540a1b608 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -180,130 +180,6 @@ static constexpr u32 HOST_PAGE_MASK = HOST_PAGE_SIZE - 1; static constexpr u32 HOST_PAGE_SHIFT = 12; #endif -// Zero-extending helper -template -ALWAYS_INLINE constexpr TReturn ZeroExtend(TValue value) -{ - return static_cast(static_cast::type>( - static_cast::type>(value))); -} -// Sign-extending helper -template -ALWAYS_INLINE constexpr TReturn SignExtend(TValue value) -{ - return static_cast( - static_cast::type>(static_cast::type>(value))); -} - -// Type-specific helpers -template -ALWAYS_INLINE constexpr u16 ZeroExtend16(TValue value) -{ - return ZeroExtend(value); -} -template -ALWAYS_INLINE constexpr u32 ZeroExtend32(TValue value) -{ - return ZeroExtend(value); -} -template -ALWAYS_INLINE constexpr u64 ZeroExtend64(TValue value) -{ - return ZeroExtend(value); -} -template -ALWAYS_INLINE constexpr u16 SignExtend16(TValue value) -{ - return SignExtend(value); -} -template -ALWAYS_INLINE constexpr u32 SignExtend32(TValue value) -{ - return SignExtend(value); -} -template -ALWAYS_INLINE constexpr u64 SignExtend64(TValue value) -{ - return SignExtend(value); -} -template -ALWAYS_INLINE constexpr u8 Truncate8(TValue value) -{ - return static_cast(static_cast::type>(value)); -} -template -ALWAYS_INLINE constexpr u16 Truncate16(TValue value) -{ - return static_cast(static_cast::type>(value)); -} -template -ALWAYS_INLINE constexpr u32 Truncate32(TValue value) -{ - return static_cast(static_cast::type>(value)); -} - -// BCD helpers -ALWAYS_INLINE constexpr u8 BinaryToBCD(u8 value) -{ - return ((value / 10) << 4) + (value % 10); -} -ALWAYS_INLINE constexpr u8 PackedBCDToBinary(u8 value) -{ - return ((value >> 4) * 10) + (value % 16); -} -ALWAYS_INLINE constexpr u8 IsValidBCDDigit(u8 digit) -{ - return (digit <= 9); -} -ALWAYS_INLINE constexpr u8 IsValidPackedBCD(u8 value) -{ - return IsValidBCDDigit(value & 0x0F) && IsValidBCDDigit(value >> 4); -} - -// Boolean to integer -ALWAYS_INLINE constexpr u8 BoolToUInt8(bool value) -{ - return static_cast(value); -} -ALWAYS_INLINE constexpr u16 BoolToUInt16(bool value) -{ - return static_cast(value); -} -ALWAYS_INLINE constexpr u32 BoolToUInt32(bool value) -{ - return static_cast(value); -} -ALWAYS_INLINE constexpr u64 BoolToUInt64(bool value) -{ - return static_cast(value); -} - -// Integer to boolean -template -ALWAYS_INLINE constexpr bool ConvertToBool(TValue value) -{ - return static_cast(value); -} - -// Unsafe integer to boolean -template -ALWAYS_INLINE bool ConvertToBoolUnchecked(TValue value) -{ - // static_assert(sizeof(uint8) == sizeof(bool)); - bool ret; - std::memcpy(&ret, &value, sizeof(bool)); - return ret; -} - -// Generic sign extension -template -ALWAYS_INLINE constexpr T SignExtendN(T value) -{ - // http://graphics.stanford.edu/~seander/bithacks.html#VariableSignExtend - constexpr int shift = 8 * sizeof(T) - NBITS; - return static_cast((static_cast>(value) << shift) >> shift); -} - // Enum class bitwise operators #define IMPLEMENT_ENUM_CLASS_BITWISE_OPERATORS(type_) \ ALWAYS_INLINE constexpr type_ operator&(type_ lhs, type_ rhs) \ diff --git a/src/core/analog_controller.cpp b/src/core/analog_controller.cpp index 11389ba1c..9311b8d8e 100644 --- a/src/core/analog_controller.cpp +++ b/src/core/analog_controller.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin and contributors. +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin and contributors. // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "analog_controller.h" @@ -10,6 +10,7 @@ #include "util/input_manager.h" #include "util/state_wrapper.h" +#include "common/bitutils.h" #include "common/log.h" #include "common/string_util.h" diff --git a/src/core/analog_joystick.cpp b/src/core/analog_joystick.cpp index 5bfc3bd35..b1ea88df3 100644 --- a/src/core/analog_joystick.cpp +++ b/src/core/analog_joystick.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin and contributors. +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin and contributors. // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "analog_joystick.h" @@ -8,6 +8,7 @@ #include "util/imgui_manager.h" #include "util/state_wrapper.h" +#include "common/bitutils.h" #include "common/log.h" #include "common/string_util.h" diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index 78180fe59..ff20df621 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "cdrom.h" @@ -21,17 +21,15 @@ #include "common/fifo_queue.h" #include "common/file_system.h" #include "common/heap_array.h" +#include "common/intrin.h" #include "common/log.h" #include "imgui.h" #include #include -Log_SetChannel(CDROM); -#if defined(CPU_ARCH_X64) -#include -#endif +Log_SetChannel(CDROM); namespace CDROM { enum : u32 @@ -3073,7 +3071,7 @@ static s16 GetPeakVolume(const u8* raw_sector, u8 channel) { static constexpr u32 NUM_SAMPLES = CDImage::RAW_SECTOR_SIZE / sizeof(s16); -#if defined(CPU_ARCH_X64) +#if defined(CPU_ARCH_SSE) static_assert(Common::IsAlignedPow2(NUM_SAMPLES, 8)); const u8* current_ptr = raw_sector; __m128i v_peak = _mm_set1_epi16(0); diff --git a/src/core/cpu_types.h b/src/core/cpu_types.h index fb5297854..a4d0548a6 100644 --- a/src/core/cpu_types.h +++ b/src/core/cpu_types.h @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once #include "common/bitfield.h" +#include "common/bitutils.h" #include "types.h" #include diff --git a/src/core/digital_controller.cpp b/src/core/digital_controller.cpp index a1657549c..02056ac58 100644 --- a/src/core/digital_controller.cpp +++ b/src/core/digital_controller.cpp @@ -1,12 +1,15 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin and contributors. +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin and contributors. // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "digital_controller.h" -#include "common/assert.h" #include "host.h" #include "system.h" + #include "util/state_wrapper.h" +#include "common/assert.h" +#include "common/bitutils.h" + DigitalController::DigitalController(u32 index) : Controller(index) { } diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index d254a3a2e..1c37e3217 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -8,6 +8,7 @@ #include "common/align.h" #include "common/assert.h" +#include "common/intrin.h" #include "common/log.h" #include "common/make_array.h" @@ -15,16 +16,6 @@ Log_SetChannel(GPU_SW); -#if defined(CPU_ARCH_X64) -#include -#elif defined(CPU_ARCH_ARM64) -#ifdef _MSC_VER -#include -#else -#include -#endif -#endif - template ALWAYS_INLINE static constexpr std::tuple MinMax(T v1, T v2) { @@ -162,7 +153,7 @@ ALWAYS_INLINE void CopyOutRow16(const u16* sr { u32 col = 0; -#if defined(CPU_ARCH_X64) +#if defined(CPU_ARCH_SSE) const u32 aligned_width = Common::AlignDownPow2(width, 8); for (; col < aligned_width; col += 8) { @@ -176,7 +167,7 @@ ALWAYS_INLINE void CopyOutRow16(const u16* sr _mm_storeu_si128(reinterpret_cast<__m128i*>(dst_ptr), value); dst_ptr += 8; } -#elif defined(CPU_ARCH_ARM64) +#elif defined(CPU_ARCH_NEON) const u32 aligned_width = Common::AlignDownPow2(width, 8); for (; col < aligned_width; col += 8) { @@ -201,7 +192,7 @@ ALWAYS_INLINE void CopyOutRow16(const u16* src_ { u32 col = 0; -#if defined(CPU_ARCH_X64) +#if defined(CPU_ARCH_SSE) const u32 aligned_width = Common::AlignDownPow2(width, 8); for (; col < aligned_width; col += 8) { @@ -216,7 +207,7 @@ ALWAYS_INLINE void CopyOutRow16(const u16* src_ _mm_storeu_si128(reinterpret_cast<__m128i*>(dst_ptr), value); dst_ptr += 8; } -#elif defined(CPU_ARCH_ARM64) +#elif defined(CPU_ARCH_NEON) const u32 aligned_width = Common::AlignDownPow2(width, 8); const uint16x8_t single_mask = vdupq_n_u16(0x1F); for (; col < aligned_width; col += 8) diff --git a/src/core/gpu_types.h b/src/core/gpu_types.h index 75bba6e5d..e0cb11e31 100644 --- a/src/core/gpu_types.h +++ b/src/core/gpu_types.h @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once #include "common/bitfield.h" +#include "common/bitutils.h" #include "common/rectangle.h" #include "types.h" #include diff --git a/src/core/imgui_overlays.cpp b/src/core/imgui_overlays.cpp index 332ee420d..b1d8685ba 100644 --- a/src/core/imgui_overlays.cpp +++ b/src/core/imgui_overlays.cpp @@ -23,6 +23,7 @@ #include "common/align.h" #include "common/assert.h" #include "common/file_system.h" +#include "common/intrin.h" #include "common/log.h" #include "common/string_util.h" #include "common/timer.h" @@ -41,16 +42,6 @@ #include #include -#if defined(CPU_ARCH_X64) -#include -#elif defined(CPU_ARCH_ARM64) -#ifdef _MSC_VER -#include -#else -#include -#endif -#endif - Log_SetChannel(ImGuiManager); namespace ImGuiManager { @@ -66,7 +57,7 @@ static void Draw(); static std::tuple GetMinMax(std::span values) { -#if defined(CPU_ARCH_X64) +#if defined(CPU_ARCH_SSE) __m128 vmin(_mm_loadu_ps(values.data())); __m128 vmax(vmin); @@ -80,7 +71,7 @@ static std::tuple GetMinMax(std::span values) vmax = _mm_max_ps(vmax, v); } -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) float min = std::min(vmin.m128_f32[0], std::min(vmin.m128_f32[1], std::min(vmin.m128_f32[2], vmin.m128_f32[3]))); float max = std::max(vmax.m128_f32[0], std::max(vmax.m128_f32[1], std::max(vmax.m128_f32[2], vmax.m128_f32[3]))); #else @@ -94,7 +85,7 @@ static std::tuple GetMinMax(std::span values) } return std::tie(min, max); -#elif defined(CPU_ARCH_ARM64) +#elif defined(CPU_ARCH_NEON) float32x4_t vmin(vld1q_f32(values.data())); float32x4_t vmax(vmin); diff --git a/src/core/memory_card.cpp b/src/core/memory_card.cpp index 4caf8f87f..8a757222a 100644 --- a/src/core/memory_card.cpp +++ b/src/core/memory_card.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "memory_card.h" @@ -8,6 +8,7 @@ #include "util/imgui_manager.h" #include "util/state_wrapper.h" +#include "common/bitutils.h" #include "common/byte_stream.h" #include "common/file_system.h" #include "common/log.h" diff --git a/src/core/memory_card_image.cpp b/src/core/memory_card_image.cpp index 7d59a6414..f7bb26eb4 100644 --- a/src/core/memory_card_image.cpp +++ b/src/core/memory_card_image.cpp @@ -1,18 +1,23 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "memory_card_image.h" +#include "system.h" + +#include "util/shiftjis.h" +#include "util/state_wrapper.h" + +#include "common/bitutils.h" #include "common/byte_stream.h" #include "common/file_system.h" #include "common/log.h" #include "common/path.h" #include "common/string_util.h" -#include "system.h" -#include "util/shiftjis.h" -#include "util/state_wrapper.h" + #include #include #include + Log_SetChannel(MemoryCard); namespace MemoryCardImage { diff --git a/src/core/negcon.cpp b/src/core/negcon.cpp index ae88f5103..df459c476 100644 --- a/src/core/negcon.cpp +++ b/src/core/negcon.cpp @@ -1,12 +1,16 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin and contributors. +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin and contributors. // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "negcon.h" -#include "common/assert.h" -#include "common/log.h" #include "host.h" #include "system.h" + #include "util/state_wrapper.h" + +#include "common/assert.h" +#include "common/bitutils.h" +#include "common/log.h" + #include #include @@ -250,7 +254,7 @@ static const Controller::ControllerBindingInfo s_binding_info[] = { BUTTON("R", TRANSLATE_NOOP("NeGcon", "Right Trigger"), NeGcon::Button::R, GenericInputBinding::R1), AXIS("SteeringLeft", TRANSLATE_NOOP("NeGcon", "Steering (Twist) Left"), NeGcon::HalfAxis::SteeringLeft, GenericInputBinding::LeftStickLeft), AXIS("SteeringRight", TRANSLATE_NOOP("NeGcon", "Steering (Twist) Right"), NeGcon::HalfAxis::SteeringRight, GenericInputBinding::LeftStickRight), - // clang-format on +// clang-format on #undef AXIS #undef BUTTON @@ -265,12 +269,9 @@ static const SettingInfo s_settings[] = { nullptr, 100.0f}, }; -const Controller::ControllerInfo NeGcon::INFO = {ControllerType::NeGcon, - "NeGcon", - TRANSLATE_NOOP("ControllerType", "NeGcon"), - s_binding_info, - s_settings, - Controller::VibrationCapabilities::NoVibration}; +const Controller::ControllerInfo NeGcon::INFO = { + ControllerType::NeGcon, "NeGcon", TRANSLATE_NOOP("ControllerType", "NeGcon"), + s_binding_info, s_settings, Controller::VibrationCapabilities::NoVibration}; void NeGcon::LoadSettings(SettingsInterface& si, const char* section) { diff --git a/src/core/pad.cpp b/src/core/pad.cpp index c302e84d3..3814f215b 100644 --- a/src/core/pad.cpp +++ b/src/core/pad.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin and contributors. +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin and contributors. // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "pad.h" @@ -15,6 +15,7 @@ #include "util/state_wrapper.h" #include "common/bitfield.h" +#include "common/bitutils.h" #include "common/fifo_queue.h" #include "common/log.h" diff --git a/src/core/sio.cpp b/src/core/sio.cpp index 83de12c78..0b4b1952a 100644 --- a/src/core/sio.cpp +++ b/src/core/sio.cpp @@ -1,16 +1,21 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "sio.h" -#include "common/bitfield.h" -#include "common/fifo_queue.h" -#include "common/log.h" #include "controller.h" #include "interrupt_controller.h" #include "memory_card.h" + #include "util/state_wrapper.h" + +#include "common/bitfield.h" +#include "common/bitutils.h" +#include "common/fifo_queue.h" +#include "common/log.h" + #include #include + Log_SetChannel(SIO); namespace SIO { diff --git a/src/core/spu.cpp b/src/core/spu.cpp index 325eb3499..5b3167d98 100644 --- a/src/core/spu.cpp +++ b/src/core/spu.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "spu.h" @@ -15,6 +15,7 @@ #include "util/wav_writer.h" #include "common/bitfield.h" +#include "common/bitutils.h" #include "common/fifo_queue.h" #include "common/log.h" #include "common/path.h" diff --git a/src/core/texture_replacements.cpp b/src/core/texture_replacements.cpp index d93b0aac2..c41469bdb 100644 --- a/src/core/texture_replacements.cpp +++ b/src/core/texture_replacements.cpp @@ -1,20 +1,25 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "texture_replacements.h" +#include "host.h" +#include "settings.h" + +#include "common/bitutils.h" #include "common/file_system.h" #include "common/log.h" #include "common/path.h" #include "common/string_util.h" #include "common/timer.h" + #include "fmt/format.h" -#include "host.h" -#include "settings.h" #include "xxhash.h" #if defined(CPU_ARCH_X86) || defined(CPU_ARCH_X64) #include "xxh_x86dispatch.h" #endif + #include + Log_SetChannel(TextureReplacements); TextureReplacements g_texture_replacements; diff --git a/src/util/audio_stream.cpp b/src/util/audio_stream.cpp index 797a4d698..0ccda38ac 100644 --- a/src/util/audio_stream.cpp +++ b/src/util/audio_stream.cpp @@ -2,30 +2,20 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "audio_stream.h" -#include "SoundTouch.h" + #include "common/align.h" #include "common/assert.h" +#include "common/intrin.h" #include "common/log.h" #include "common/make_array.h" #include "common/timer.h" + +#include "SoundTouch.h" + #include #include #include -#ifdef __APPLE__ -#include // alloca -#else -#include // alloca -#endif - -#if defined(_M_ARM64) -#include -#elif defined(__aarch64__) -#include -#elif defined(CPU_ARCH_X86) || defined(CPU_ARCH_X64) -#include -#endif - Log_SetChannel(AudioStream); static constexpr bool LOG_TIMESTRETCH_STATS = false; @@ -364,7 +354,7 @@ void AudioStream::EndWrite(u32 num_frames) static constexpr float S16_TO_FLOAT = 1.0f / 32767.0f; static constexpr float FLOAT_TO_S16 = 32767.0f; -#if defined(CPU_ARCH_ARM64) +#if defined(CPU_ARCH_NEON) static void S16ChunkToFloat(const s32* src, float* dst) { @@ -417,7 +407,7 @@ static void FloatChunkToS16(s32* dst, const float* src, uint size) } } -#elif defined(CPU_ARCH_X86) || defined(CPU_ARCH_X64) +#elif defined(CPU_ARCH_SSE) static void S16ChunkToFloat(const s32* src, float* dst) { diff --git a/src/util/cd_image.h b/src/util/cd_image.h index fd4a5e6de..1ad169b7f 100644 --- a/src/util/cd_image.h +++ b/src/util/cd_image.h @@ -3,6 +3,7 @@ #pragma once #include "common/bitfield.h" +#include "common/bitutils.h" #include "common/progress_callback.h" #include "common/types.h" #include diff --git a/src/util/d3d11_device.cpp b/src/util/d3d11_device.cpp index 85ee28981..147705006 100644 --- a/src/util/d3d11_device.cpp +++ b/src/util/d3d11_device.cpp @@ -9,6 +9,7 @@ #include "common/align.h" #include "common/assert.h" +#include "common/bitutils.h" #include "common/file_system.h" #include "common/log.h" #include "common/path.h" diff --git a/src/util/gpu_texture.cpp b/src/util/gpu_texture.cpp index a08ae9b5c..f5f635ea6 100644 --- a/src/util/gpu_texture.cpp +++ b/src/util/gpu_texture.cpp @@ -4,6 +4,7 @@ #include "gpu_texture.h" #include "gpu_device.h" +#include "common/bitutils.h" #include "common/log.h" #include "common/string_util.h" diff --git a/src/util/shadergen.cpp b/src/util/shadergen.cpp index c1b80b241..2c5508e10 100644 --- a/src/util/shadergen.cpp +++ b/src/util/shadergen.cpp @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "shadergen.h" #include "common/assert.h" +#include "common/bitutils.h" #include "common/log.h" #include #include