Common: Add intrin.h

This commit is contained in:
Stenzek 2023-10-01 14:12:25 +10:00
parent b1bb33a566
commit 01e505ec8b
26 changed files with 235 additions and 206 deletions

View file

@ -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

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
@ -8,6 +8,130 @@
#include <intrin.h>
#endif
// Zero-extending helper
template<typename TReturn, typename TValue>
ALWAYS_INLINE constexpr TReturn ZeroExtend(TValue value)
{
return static_cast<TReturn>(static_cast<typename std::make_unsigned<TReturn>::type>(
static_cast<typename std::make_unsigned<TValue>::type>(value)));
}
// Sign-extending helper
template<typename TReturn, typename TValue>
ALWAYS_INLINE constexpr TReturn SignExtend(TValue value)
{
return static_cast<TReturn>(
static_cast<typename std::make_signed<TReturn>::type>(static_cast<typename std::make_signed<TValue>::type>(value)));
}
// Type-specific helpers
template<typename TValue>
ALWAYS_INLINE constexpr u16 ZeroExtend16(TValue value)
{
return ZeroExtend<u16, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u32 ZeroExtend32(TValue value)
{
return ZeroExtend<u32, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u64 ZeroExtend64(TValue value)
{
return ZeroExtend<u64, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u16 SignExtend16(TValue value)
{
return SignExtend<u16, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u32 SignExtend32(TValue value)
{
return SignExtend<u32, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u64 SignExtend64(TValue value)
{
return SignExtend<u64, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u8 Truncate8(TValue value)
{
return static_cast<u8>(static_cast<typename std::make_unsigned<decltype(value)>::type>(value));
}
template<typename TValue>
ALWAYS_INLINE constexpr u16 Truncate16(TValue value)
{
return static_cast<u16>(static_cast<typename std::make_unsigned<decltype(value)>::type>(value));
}
template<typename TValue>
ALWAYS_INLINE constexpr u32 Truncate32(TValue value)
{
return static_cast<u32>(static_cast<typename std::make_unsigned<decltype(value)>::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<u8>(value);
}
ALWAYS_INLINE constexpr u16 BoolToUInt16(bool value)
{
return static_cast<u16>(value);
}
ALWAYS_INLINE constexpr u32 BoolToUInt32(bool value)
{
return static_cast<u32>(value);
}
ALWAYS_INLINE constexpr u64 BoolToUInt64(bool value)
{
return static_cast<u64>(value);
}
// Integer to boolean
template<typename TValue>
ALWAYS_INLINE constexpr bool ConvertToBool(TValue value)
{
return static_cast<bool>(value);
}
// Unsafe integer to boolean
template<typename TValue>
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<int NBITS, typename T>
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<T>((static_cast<std::make_signed_t<T>>(value) << shift) >> shift);
}
/// Returns the number of zero bits before the first set bit, going MSB->LSB.
template<typename T>
ALWAYS_INLINE unsigned CountLeadingZeros(T value)

View file

@ -20,6 +20,7 @@
<ClInclude Include="http_downloader.h" />
<ClInclude Include="http_downloader_winhttp.h" />
<ClInclude Include="image.h" />
<ClInclude Include="intrin.h" />
<ClInclude Include="layered_settings_interface.h" />
<ClInclude Include="log.h" />
<ClInclude Include="lru_cache.h" />

View file

@ -43,6 +43,7 @@
<ClInclude Include="sha1_digest.h" />
<ClInclude Include="fastjmp.h" />
<ClInclude Include="memmap.h" />
<ClInclude Include="intrin.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="small_string.cpp" />

26
src/common/intrin.h Normal file
View file

@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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 <emmintrin.h>
#elif defined(CPU_ARCH_ARM64)
#define CPU_ARCH_NEON 1
#ifdef _MSC_VER
#include <arm64_neon.h>
#else
#include <arm_neon.h>
#endif
#endif
#ifdef __APPLE__
#include <stdlib.h> // alloca
#else
#include <malloc.h> // alloca
#endif

View file

@ -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<typename TReturn, typename TValue>
ALWAYS_INLINE constexpr TReturn ZeroExtend(TValue value)
{
return static_cast<TReturn>(static_cast<typename std::make_unsigned<TReturn>::type>(
static_cast<typename std::make_unsigned<TValue>::type>(value)));
}
// Sign-extending helper
template<typename TReturn, typename TValue>
ALWAYS_INLINE constexpr TReturn SignExtend(TValue value)
{
return static_cast<TReturn>(
static_cast<typename std::make_signed<TReturn>::type>(static_cast<typename std::make_signed<TValue>::type>(value)));
}
// Type-specific helpers
template<typename TValue>
ALWAYS_INLINE constexpr u16 ZeroExtend16(TValue value)
{
return ZeroExtend<u16, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u32 ZeroExtend32(TValue value)
{
return ZeroExtend<u32, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u64 ZeroExtend64(TValue value)
{
return ZeroExtend<u64, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u16 SignExtend16(TValue value)
{
return SignExtend<u16, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u32 SignExtend32(TValue value)
{
return SignExtend<u32, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u64 SignExtend64(TValue value)
{
return SignExtend<u64, TValue>(value);
}
template<typename TValue>
ALWAYS_INLINE constexpr u8 Truncate8(TValue value)
{
return static_cast<u8>(static_cast<typename std::make_unsigned<decltype(value)>::type>(value));
}
template<typename TValue>
ALWAYS_INLINE constexpr u16 Truncate16(TValue value)
{
return static_cast<u16>(static_cast<typename std::make_unsigned<decltype(value)>::type>(value));
}
template<typename TValue>
ALWAYS_INLINE constexpr u32 Truncate32(TValue value)
{
return static_cast<u32>(static_cast<typename std::make_unsigned<decltype(value)>::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<u8>(value);
}
ALWAYS_INLINE constexpr u16 BoolToUInt16(bool value)
{
return static_cast<u16>(value);
}
ALWAYS_INLINE constexpr u32 BoolToUInt32(bool value)
{
return static_cast<u32>(value);
}
ALWAYS_INLINE constexpr u64 BoolToUInt64(bool value)
{
return static_cast<u64>(value);
}
// Integer to boolean
template<typename TValue>
ALWAYS_INLINE constexpr bool ConvertToBool(TValue value)
{
return static_cast<bool>(value);
}
// Unsafe integer to boolean
template<typename TValue>
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<int NBITS, typename T>
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<T>((static_cast<std::make_signed_t<T>>(value) << shift) >> shift);
}
// Enum class bitwise operators
#define IMPLEMENT_ENUM_CLASS_BITWISE_OPERATORS(type_) \
ALWAYS_INLINE constexpr type_ operator&(type_ lhs, type_ rhs) \

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> and contributors.
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> 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"

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> and contributors.
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> 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"

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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 <cmath>
#include <vector>
Log_SetChannel(CDROM);
#if defined(CPU_ARCH_X64)
#include <emmintrin.h>
#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);

View file

@ -1,8 +1,9 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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 <optional>

View file

@ -1,12 +1,15 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> and contributors.
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> 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)
{
}

View file

@ -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 <emmintrin.h>
#elif defined(CPU_ARCH_ARM64)
#ifdef _MSC_VER
#include <arm64_neon.h>
#else
#include <arm_neon.h>
#endif
#endif
template<typename T>
ALWAYS_INLINE static constexpr std::tuple<T, T> MinMax(T v1, T v2)
{
@ -162,7 +153,7 @@ ALWAYS_INLINE void CopyOutRow16<GPUTexture::Format::RGBA5551, u16>(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<GPUTexture::Format::RGBA5551, u16>(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<GPUTexture::Format::RGB565, u16>(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<GPUTexture::Format::RGB565, u16>(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)

View file

@ -1,8 +1,9 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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 <array>

View file

@ -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 <span>
#include <unordered_map>
#if defined(CPU_ARCH_X64)
#include <emmintrin.h>
#elif defined(CPU_ARCH_ARM64)
#ifdef _MSC_VER
#include <arm64_neon.h>
#else
#include <arm_neon.h>
#endif
#endif
Log_SetChannel(ImGuiManager);
namespace ImGuiManager {
@ -66,7 +57,7 @@ static void Draw();
static std::tuple<float, float> GetMinMax(std::span<const float> 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<float, float> GetMinMax(std::span<const float> 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<float, float> GetMinMax(std::span<const float> 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);

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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"

View file

@ -1,18 +1,23 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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 <algorithm>
#include <cstdio>
#include <optional>
Log_SetChannel(MemoryCard);
namespace MemoryCardImage {

View file

@ -1,12 +1,16 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> and contributors.
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> 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 <array>
#include <cmath>
@ -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)
{

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> and contributors.
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> 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"

View file

@ -1,16 +1,21 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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 <array>
#include <memory>
Log_SetChannel(SIO);
namespace SIO {

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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"

View file

@ -1,20 +1,25 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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 <cinttypes>
Log_SetChannel(TextureReplacements);
TextureReplacements g_texture_replacements;

View file

@ -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 <algorithm>
#include <cmath>
#include <cstring>
#ifdef __APPLE__
#include <stdlib.h> // alloca
#else
#include <malloc.h> // alloca
#endif
#if defined(_M_ARM64)
#include <arm64_neon.h>
#elif defined(__aarch64__)
#include <arm_neon.h>
#elif defined(CPU_ARCH_X86) || defined(CPU_ARCH_X64)
#include <emmintrin.h>
#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)
{

View file

@ -3,6 +3,7 @@
#pragma once
#include "common/bitfield.h"
#include "common/bitutils.h"
#include "common/progress_callback.h"
#include "common/types.h"
#include <array>

View file

@ -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"

View file

@ -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"

View file

@ -1,8 +1,9 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// 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 <cstdio>
#include <cstring>