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

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