mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-16 00:05:05 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fa4e7c6992 | |||
| b77308ced6 |
@@ -110,6 +110,7 @@ add_library(
|
||||
socket_types.h
|
||||
sparse_large_vector.cpp
|
||||
sparse_large_vector.h
|
||||
spin_lock.h
|
||||
stb.cpp
|
||||
stb.h
|
||||
steady_clock.cpp
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
#elif defined(ARCHITECTURE_x86_64)
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
#include <atomic>
|
||||
|
||||
namespace Common {
|
||||
|
||||
/// @brief A lock similar to mutex that forces a thread to spin wait instead calling the
|
||||
/// supervisor. Should be used on short sequences of code.
|
||||
struct SpinLock {
|
||||
SpinLock() noexcept = default;
|
||||
SpinLock(const SpinLock&) noexcept = delete;
|
||||
SpinLock& operator=(const SpinLock&) noexcept = delete;
|
||||
SpinLock(SpinLock&&) noexcept = delete;
|
||||
SpinLock& operator=(SpinLock&&) noexcept = delete;
|
||||
|
||||
inline void lock() noexcept {
|
||||
while (lck.test_and_set(std::memory_order_acquire)) {
|
||||
#if defined(ARCHITECTURE_x86_64)
|
||||
_mm_pause();
|
||||
#elif defined(ARCHITECTURE_arm64) && defined(_MSC_VER)
|
||||
__yield();
|
||||
#elif defined(ARCHITECTURE_arm64)
|
||||
asm("yield");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline void unlock() noexcept {
|
||||
lck.clear(std::memory_order_release);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool try_lock() noexcept {
|
||||
return !lck.test_and_set(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
std::atomic_flag lck = ATOMIC_FLAG_INIT;
|
||||
};
|
||||
|
||||
} // namespace Common
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "hid_core/frontend/emulated_controller.h"
|
||||
#include "hid_core/hid_core.h"
|
||||
#include "hid_core/hid_types.h"
|
||||
#include <array>
|
||||
|
||||
namespace Core::Frontend {
|
||||
|
||||
@@ -29,23 +30,39 @@ void DefaultControllerApplet::ReconfigureControllers(ReconfigureCallback callbac
|
||||
|
||||
const std::size_t min_supported_players =
|
||||
parameters.enable_single_mode ? 1 : parameters.min_players;
|
||||
using Core::HID::NpadStyleIndex;
|
||||
const std::size_t max_supported_players = parameters.enable_single_mode ? 1 : parameters.max_players;
|
||||
std::size_t num_selected_players = 0;
|
||||
std::array<bool, HID::HIDCore::available_controllers> keep_connected{};
|
||||
|
||||
// Disconnect Handheld first.
|
||||
// reserve existing AND valid players before filling slots. include Handheld, but not other
|
||||
for (std::size_t index = 0; index < hid_core.available_controllers - 1; ++index) {
|
||||
const auto* controller = hid_core.GetEmulatedControllerByIndex(index);
|
||||
if (!parameters.keep_controllers_connected || !controller->IsConnected() || num_selected_players >= max_supported_players) continue;
|
||||
|
||||
const auto style = controller->GetNpadStyleIndex();
|
||||
keep_connected[index] =
|
||||
(style == NpadStyleIndex::Fullkey && parameters.allow_pro_controller) ||
|
||||
(style == NpadStyleIndex::JoyconDual && parameters.allow_dual_joycons) ||
|
||||
(style == NpadStyleIndex::JoyconLeft && parameters.allow_left_joycon) ||
|
||||
(style == NpadStyleIndex::JoyconRight && parameters.allow_right_joycon) ||
|
||||
(style == NpadStyleIndex::Handheld && parameters.enable_single_mode && parameters.allow_handheld && !Settings::IsDockedMode()) ||
|
||||
(style == NpadStyleIndex::GameCube && parameters.allow_gamecube_controller);
|
||||
num_selected_players += keep_connected[index];
|
||||
}
|
||||
auto* handheld = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||
handheld->Disconnect();
|
||||
if (!keep_connected[hid_core.available_controllers - 2]) handheld->Disconnect();
|
||||
|
||||
// Deduce the best configuration based on the input parameters.
|
||||
for (std::size_t index = 0; index < hid_core.available_controllers - 2; ++index) {
|
||||
auto* controller = hid_core.GetEmulatedControllerByIndex(index);
|
||||
|
||||
// First, disconnect all controllers regardless of the value of keep_controllers_connected.
|
||||
// This makes it easy to connect the desired controllers.
|
||||
if (keep_connected[index]) continue;
|
||||
controller->Disconnect();
|
||||
|
||||
// Only connect the minimum number of required players.
|
||||
if (index >= min_supported_players) {
|
||||
continue;
|
||||
}
|
||||
// only add players still needed to reach the minimum
|
||||
if (num_selected_players >= min_supported_players) continue;
|
||||
++num_selected_players;
|
||||
|
||||
// Connect controllers based on the following priority list from highest to lowest priority:
|
||||
// Pro Controller -> Dual Joycons -> Left Joycon/Right Joycon -> Handheld
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "common/atomic_ops.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/spin_lock.h"
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
@@ -29,7 +30,7 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
KSlabHeapImpl() = default;
|
||||
constexpr KSlabHeapImpl() = default;
|
||||
|
||||
void Initialize() {
|
||||
ASSERT(m_head == nullptr);
|
||||
@@ -67,7 +68,7 @@ public:
|
||||
|
||||
private:
|
||||
std::atomic<Node*> m_head{};
|
||||
std::mutex m_lock;
|
||||
Common::SpinLock m_lock;
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "common/intrusive_red_black_tree.h"
|
||||
#include "common/scratch_buffer.h"
|
||||
#include "common/spin_lock.h"
|
||||
#include "core/arm/arm_interface.h"
|
||||
#include "core/hle/kernel/k_affinity_mask.h"
|
||||
#include "core/hle/kernel/k_light_lock.h"
|
||||
@@ -919,7 +920,7 @@ private:
|
||||
bool m_resource_limit_release_hint{};
|
||||
bool m_is_kernel_address_key{};
|
||||
StackParameters m_stack_parameters{};
|
||||
std::mutex m_context_guard{};
|
||||
Common::SpinLock m_context_guard{};
|
||||
|
||||
// For emulation
|
||||
std::shared_ptr<Common::Fiber> m_host_context{};
|
||||
|
||||
@@ -2850,8 +2850,6 @@ Sampler::VariantKey Sampler::MakeKey(const ImageView& image_view, bool is_depth)
|
||||
VariantKey key{};
|
||||
key.reduce_anisotropy = has_added_anisotropy && !image_view.SupportsAnisotropy();
|
||||
key.force_nearest = has_linear_filtering && IsPixelFormatInteger(image_view.format);
|
||||
key.drop_depth_comparison =
|
||||
is_depth && has_depth_comparison && !image_view.SupportsDepthComparison();
|
||||
key.drop_reduction = has_minmax_reduction && !image_view.SupportsMinmaxFilter();
|
||||
key.drop_custom_border = has_custom_border_colors && image_view.RequiresBorderColorFormat();
|
||||
key.srgb_border = has_srgb_border_color && IsPixelFormatSRGB(image_view.format);
|
||||
@@ -2929,9 +2927,6 @@ VkSampler Sampler::Emplace(VariantKey key) {
|
||||
create_info.anisotropyEnable = static_cast<VkBool32>(default_anisotropy > 1.0f);
|
||||
create_info.maxAnisotropy = default_anisotropy;
|
||||
}
|
||||
if (key.drop_depth_comparison) {
|
||||
create_info.compareEnable = VK_FALSE;
|
||||
}
|
||||
if (!custom_border) {
|
||||
create_info.borderColor = ConvertBorderColor(color);
|
||||
}
|
||||
|
||||
@@ -536,7 +536,6 @@ private:
|
||||
struct VariantKey {
|
||||
bool reduce_anisotropy;
|
||||
bool force_nearest;
|
||||
bool drop_depth_comparison;
|
||||
bool drop_reduction;
|
||||
bool drop_custom_border;
|
||||
bool srgb_border;
|
||||
|
||||
Reference in New Issue
Block a user