mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-20 06:53:11 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d683010a8b | |||
| ec254a3adb | |||
| 5e10da3cac |
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -8,10 +11,11 @@
|
|||||||
|
|
||||||
namespace AudioCore {
|
namespace AudioCore {
|
||||||
|
|
||||||
AudioCore::AudioCore(Core::System& system) : audio_manager{std::make_unique<AudioManager>()} {
|
AudioCore::AudioCore(Core::System& system) {
|
||||||
|
audio_manager.emplace();
|
||||||
CreateSinks();
|
CreateSinks();
|
||||||
// Must be created after the sinks
|
// Must be created after the sinks
|
||||||
adsp = std::make_unique<ADSP::ADSP>(system, *output_sink);
|
adsp.emplace(system, *output_sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioCore ::~AudioCore() {
|
AudioCore ::~AudioCore() {
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -15,10 +18,7 @@ class System;
|
|||||||
|
|
||||||
namespace AudioCore {
|
namespace AudioCore {
|
||||||
|
|
||||||
class AudioManager;
|
/// @brief Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP.
|
||||||
/**
|
|
||||||
* Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP.
|
|
||||||
*/
|
|
||||||
class AudioCore {
|
class AudioCore {
|
||||||
public:
|
public:
|
||||||
explicit AudioCore(Core::System& system);
|
explicit AudioCore(Core::System& system);
|
||||||
@@ -50,27 +50,22 @@ public:
|
|||||||
*/
|
*/
|
||||||
Sink::Sink& GetInputSink();
|
Sink::Sink& GetInputSink();
|
||||||
|
|
||||||
/**
|
/// @brief Get the ADSP.
|
||||||
* Get the ADSP.
|
/// @return Ref to the ADSP.
|
||||||
*
|
|
||||||
* @return Ref to the ADSP.
|
|
||||||
*/
|
|
||||||
ADSP::ADSP& ADSP();
|
ADSP::ADSP& ADSP();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/// @brief Create the sinks on startup.
|
||||||
* Create the sinks on startup.
|
|
||||||
*/
|
|
||||||
void CreateSinks();
|
void CreateSinks();
|
||||||
|
|
||||||
/// Main audio manager for audio in/out
|
/// Main audio manager for audio in/out
|
||||||
std::unique_ptr<AudioManager> audio_manager;
|
std::optional<AudioManager> audio_manager;
|
||||||
/// Sink used for audio renderer and audio out
|
/// Sink used for audio renderer and audio out
|
||||||
std::unique_ptr<Sink::Sink> output_sink;
|
std::unique_ptr<Sink::Sink> output_sink;
|
||||||
/// Sink used for audio input
|
/// Sink used for audio input
|
||||||
std::unique_ptr<Sink::Sink> input_sink;
|
std::unique_ptr<Sink::Sink> input_sink;
|
||||||
/// The ADSP in the sysmodule
|
/// The ADSP in the sysmodule
|
||||||
std::unique_ptr<ADSP::ADSP> adsp;
|
std::optional<ADSP::ADSP> adsp;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace AudioCore
|
} // namespace AudioCore
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -41,8 +44,7 @@ void Manager::ReleaseSessionId(const size_t session_id) {
|
|||||||
Result Manager::LinkToManager() {
|
Result Manager::LinkToManager() {
|
||||||
std::scoped_lock l{mutex};
|
std::scoped_lock l{mutex};
|
||||||
if (!linked_to_manager) {
|
if (!linked_to_manager) {
|
||||||
AudioManager& manager{system.AudioCore().GetAudioManager()};
|
system.AudioCore().GetAudioManager().SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this));
|
||||||
manager.SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this));
|
|
||||||
linked_to_manager = true;
|
linked_to_manager = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,81 +1,77 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "audio_core/audio_manager.h"
|
#include "audio_core/audio_manager.h"
|
||||||
|
#include "common/thread.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/service/audio/errors.h"
|
#include "core/hle/service/audio/errors.h"
|
||||||
|
|
||||||
namespace AudioCore {
|
namespace AudioCore {
|
||||||
|
|
||||||
AudioManager::AudioManager() {
|
AudioManager::AudioManager() {
|
||||||
thread = std::jthread([this]() { ThreadFunc(); });
|
thread = std::jthread([this](std::stop_token stop_token) {
|
||||||
|
Common::SetCurrentThreadName("AudioManager");
|
||||||
|
std::unique_lock l{events.GetAudioEventLock()};
|
||||||
|
events.ClearEvents();
|
||||||
|
while (!stop_token.stop_requested()) {
|
||||||
|
const auto timed_out{events.Wait(l, std::chrono::seconds(2))};
|
||||||
|
if (events.CheckAudioEventSet(Event::Type::Max)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < buffer_events.size(); i++) {
|
||||||
|
const auto event_type = Event::Type(i);
|
||||||
|
if (events.CheckAudioEventSet(event_type) || timed_out) {
|
||||||
|
if (buffer_events[i]) {
|
||||||
|
buffer_events[i]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
events.SetAudioEvent(event_type, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioManager::Shutdown() {
|
void AudioManager::Shutdown() {
|
||||||
running = false;
|
|
||||||
events.SetAudioEvent(Event::Type::Max, true);
|
events.SetAudioEvent(Event::Type::Max, true);
|
||||||
thread.join();
|
if (thread.joinable()) {
|
||||||
|
thread.request_stop();
|
||||||
|
thread.join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result AudioManager::SetOutManager(BufferEventFunc buffer_func) {
|
Result AudioManager::SetOutManager(BufferEventFunc buffer_func) {
|
||||||
if (!running) {
|
if (thread.joinable()) {
|
||||||
return Service::Audio::ResultOperationFailed;
|
std::scoped_lock l{lock};
|
||||||
|
const auto index{events.GetManagerIndex(Event::Type::AudioOutManager)};
|
||||||
|
if (buffer_events[index] == nullptr) {
|
||||||
|
buffer_events[index] = std::move(buffer_func);
|
||||||
|
needs_update = true;
|
||||||
|
events.SetAudioEvent(Event::Type::AudioOutManager, true);
|
||||||
|
}
|
||||||
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
return Service::Audio::ResultOperationFailed;
|
||||||
std::scoped_lock l{lock};
|
|
||||||
|
|
||||||
const auto index{events.GetManagerIndex(Event::Type::AudioOutManager)};
|
|
||||||
if (buffer_events[index] == nullptr) {
|
|
||||||
buffer_events[index] = std::move(buffer_func);
|
|
||||||
needs_update = true;
|
|
||||||
events.SetAudioEvent(Event::Type::AudioOutManager, true);
|
|
||||||
}
|
|
||||||
return ResultSuccess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result AudioManager::SetInManager(BufferEventFunc buffer_func) {
|
Result AudioManager::SetInManager(BufferEventFunc buffer_func) {
|
||||||
if (!running) {
|
if (thread.joinable()) {
|
||||||
return Service::Audio::ResultOperationFailed;
|
std::scoped_lock l{lock};
|
||||||
|
const auto index{events.GetManagerIndex(Event::Type::AudioInManager)};
|
||||||
|
if (buffer_events[index] == nullptr) {
|
||||||
|
buffer_events[index] = std::move(buffer_func);
|
||||||
|
needs_update = true;
|
||||||
|
events.SetAudioEvent(Event::Type::AudioInManager, true);
|
||||||
|
}
|
||||||
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
return Service::Audio::ResultOperationFailed;
|
||||||
std::scoped_lock l{lock};
|
|
||||||
|
|
||||||
const auto index{events.GetManagerIndex(Event::Type::AudioInManager)};
|
|
||||||
if (buffer_events[index] == nullptr) {
|
|
||||||
buffer_events[index] = std::move(buffer_func);
|
|
||||||
needs_update = true;
|
|
||||||
events.SetAudioEvent(Event::Type::AudioInManager, true);
|
|
||||||
}
|
|
||||||
return ResultSuccess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioManager::SetEvent(const Event::Type type, const bool signalled) {
|
void AudioManager::SetEvent(const Event::Type type, const bool signalled) {
|
||||||
events.SetAudioEvent(type, signalled);
|
events.SetAudioEvent(type, signalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioManager::ThreadFunc() {
|
|
||||||
std::unique_lock l{events.GetAudioEventLock()};
|
|
||||||
events.ClearEvents();
|
|
||||||
running = true;
|
|
||||||
|
|
||||||
while (running) {
|
|
||||||
const auto timed_out{events.Wait(l, std::chrono::seconds(2))};
|
|
||||||
|
|
||||||
if (events.CheckAudioEventSet(Event::Type::Max)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < buffer_events.size(); i++) {
|
|
||||||
const auto event_type = static_cast<Event::Type>(i);
|
|
||||||
|
|
||||||
if (events.CheckAudioEventSet(event_type) || timed_out) {
|
|
||||||
if (buffer_events[i]) {
|
|
||||||
buffer_events[i]();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
events.SetAudioEvent(event_type, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace AudioCore
|
} // namespace AudioCore
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -66,13 +69,6 @@ public:
|
|||||||
void SetEvent(Event::Type type, bool signalled);
|
void SetEvent(Event::Type type, bool signalled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
|
||||||
* Main thread, waiting on a manager signal and calling the registered function.
|
|
||||||
*/
|
|
||||||
void ThreadFunc();
|
|
||||||
|
|
||||||
/// Is the main thread running?
|
|
||||||
std::atomic<bool> running{};
|
|
||||||
/// Unused
|
/// Unused
|
||||||
bool needs_update{};
|
bool needs_update{};
|
||||||
/// Events to be set and signalled
|
/// Events to be set and signalled
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -40,8 +43,7 @@ void Manager::ReleaseSessionId(const size_t session_id) {
|
|||||||
Result Manager::LinkToManager() {
|
Result Manager::LinkToManager() {
|
||||||
std::scoped_lock l{mutex};
|
std::scoped_lock l{mutex};
|
||||||
if (!linked_to_manager) {
|
if (!linked_to_manager) {
|
||||||
AudioManager& manager{system.AudioCore().GetAudioManager()};
|
system.AudioCore().GetAudioManager().SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this));
|
||||||
manager.SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this));
|
|
||||||
linked_to_manager = true;
|
linked_to_manager = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -347,7 +347,7 @@ struct System::Impl {
|
|||||||
|
|
||||||
// Register with applet manager
|
// Register with applet manager
|
||||||
// All threads are started, begin main process execution, now that we're in the clear
|
// All threads are started, begin main process execution, now that we're in the clear
|
||||||
applet_manager.CreateAndInsertByFrontendAppletParameters(std::move(process), params);
|
applet_manager.CreateAndInsertByFrontendAppletParameters(std::make_unique<Service::Process>(*std::move(process)), params);
|
||||||
|
|
||||||
if (Settings::values.gamecard_inserted) {
|
if (Settings::values.gamecard_inserted) {
|
||||||
if (Settings::values.gamecard_current_game) {
|
if (Settings::values.gamecard_current_game) {
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ void AppletManager::SetWindowSystem(WindowSystem* window_system) {
|
|||||||
|
|
||||||
if (Settings::values.enable_overlay && m_window_system->GetOverlayDisplayApplet() == nullptr) {
|
if (Settings::values.enable_overlay && m_window_system->GetOverlayDisplayApplet() == nullptr) {
|
||||||
if (auto overlay_process = CreateProcess(m_system, static_cast<u64>(AppletProgramId::OverlayDisplay), 0, 0)) {
|
if (auto overlay_process = CreateProcess(m_system, static_cast<u64>(AppletProgramId::OverlayDisplay), 0, 0)) {
|
||||||
auto overlay_applet = std::make_shared<Applet>(m_system, std::move(overlay_process), false);
|
auto overlay_applet = std::make_shared<Applet>(m_system, std::make_unique<Service::Process>(*std::move(overlay_process)), false);
|
||||||
overlay_applet->program_id = static_cast<u64>(AppletProgramId::OverlayDisplay);
|
overlay_applet->program_id = static_cast<u64>(AppletProgramId::OverlayDisplay);
|
||||||
overlay_applet->applet_id = AppletId::OverlayDisplay;
|
overlay_applet->applet_id = AppletId::OverlayDisplay;
|
||||||
overlay_applet->type = AppletType::OverlayApplet;
|
overlay_applet->type = AppletType::OverlayApplet;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include "common/thread.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/service/am/am_types.h"
|
#include "core/hle/service/am/am_types.h"
|
||||||
#include "core/hle/service/am/button_poller.h"
|
#include "core/hle/service/am/button_poller.h"
|
||||||
@@ -34,16 +36,15 @@ ButtonPressDuration ClassifyPressDuration(std::chrono::steady_clock::time_point
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ButtonPoller::ButtonPoller(Core::System& system, WindowSystem& window_system)
|
ButtonPoller::ButtonPoller(Core::System& system, WindowSystem& window_system) {
|
||||||
: m_window_system(window_system) {
|
|
||||||
// TODO: am reads this from the home button state in hid, which is controller-agnostic.
|
// TODO: am reads this from the home button state in hid, which is controller-agnostic.
|
||||||
Core::HID::ControllerUpdateCallback engine_callback{
|
Core::HID::ControllerUpdateCallback engine_callback{
|
||||||
.on_change =
|
.on_change = [this, &window_system](Core::HID::ControllerTriggerType type) {
|
||||||
[this](Core::HID::ControllerTriggerType type) {
|
if (type == Core::HID::ControllerTriggerType::Button) {
|
||||||
if (type == Core::HID::ControllerTriggerType::Button) {
|
std::unique_lock lk{m_mutex};
|
||||||
this->OnButtonStateChanged();
|
OnButtonStateChanged(window_system);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.is_npad_service = true,
|
.is_npad_service = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,25 +53,35 @@ ButtonPoller::ButtonPoller(Core::System& system, WindowSystem& window_system)
|
|||||||
m_player1 = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
|
m_player1 = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||||
m_player1_key = m_player1->SetCallback(engine_callback);
|
m_player1_key = m_player1->SetCallback(engine_callback);
|
||||||
|
|
||||||
m_thread = std::thread([this] { this->ThreadLoop(); });
|
m_thread = std::jthread([this, &window_system](std::stop_token stop_token) {
|
||||||
|
Common::SetCurrentThreadName("ButtonPoller");
|
||||||
|
while (!stop_token.stop_requested()) {
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
std::unique_lock lk{m_mutex};
|
||||||
|
m_cv.wait_for(lk, 50ms);
|
||||||
|
if (stop_token.stop_requested())
|
||||||
|
break;
|
||||||
|
OnButtonStateChanged(window_system);
|
||||||
|
std::this_thread::sleep_for(5ms);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonPoller::~ButtonPoller() {
|
ButtonPoller::~ButtonPoller() {
|
||||||
m_handheld->DeleteCallback(m_handheld_key);
|
m_handheld->DeleteCallback(m_handheld_key);
|
||||||
m_player1->DeleteCallback(m_player1_key);
|
m_player1->DeleteCallback(m_player1_key);
|
||||||
m_stop = true;
|
|
||||||
m_cv.notify_all();
|
m_cv.notify_all();
|
||||||
if (m_thread.joinable()) {
|
if (m_thread.joinable()) {
|
||||||
|
m_thread.request_stop();
|
||||||
m_thread.join();
|
m_thread.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonPoller::OnButtonStateChanged() {
|
void ButtonPoller::OnButtonStateChanged(WindowSystem& window_system) {
|
||||||
std::lock_guard lk{m_mutex};
|
auto const home_button = m_handheld->GetHomeButtons().home.Value()
|
||||||
const bool home_button =
|
|| m_player1->GetHomeButtons().home.Value();
|
||||||
m_handheld->GetHomeButtons().home.Value() || m_player1->GetHomeButtons().home.Value();
|
auto const capture_button = m_handheld->GetCaptureButtons().capture.Value()
|
||||||
const bool capture_button = m_handheld->GetCaptureButtons().capture.Value() ||
|
|| m_player1->GetCaptureButtons().capture.Value();
|
||||||
m_player1->GetCaptureButtons().capture.Value();
|
|
||||||
|
|
||||||
// Buttons pressed which were not previously pressed
|
// Buttons pressed which were not previously pressed
|
||||||
if (home_button && !m_home_button_press_start) {
|
if (home_button && !m_home_button_press_start) {
|
||||||
@@ -90,7 +101,7 @@ void ButtonPoller::OnButtonStateChanged() {
|
|||||||
if (home_button && m_home_button_press_start && !m_home_button_long_sent) {
|
if (home_button && m_home_button_press_start && !m_home_button_long_sent) {
|
||||||
const auto duration = ClassifyPressDuration(*m_home_button_press_start);
|
const auto duration = ClassifyPressDuration(*m_home_button_press_start);
|
||||||
if (duration != ButtonPressDuration::ShortPressing) {
|
if (duration != ButtonPressDuration::ShortPressing) {
|
||||||
m_window_system.OnSystemButtonPress(SystemButtonType::HomeButtonLongPressing);
|
window_system.OnSystemButtonPress(SystemButtonType::HomeButtonLongPressing);
|
||||||
m_home_button_long_sent = true;
|
m_home_button_long_sent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +109,7 @@ void ButtonPoller::OnButtonStateChanged() {
|
|||||||
if (capture_button && m_capture_button_press_start && !m_capture_button_long_sent) {
|
if (capture_button && m_capture_button_press_start && !m_capture_button_long_sent) {
|
||||||
const auto duration = ClassifyPressDuration(*m_capture_button_press_start);
|
const auto duration = ClassifyPressDuration(*m_capture_button_press_start);
|
||||||
if (duration != ButtonPressDuration::ShortPressing) {
|
if (duration != ButtonPressDuration::ShortPressing) {
|
||||||
m_window_system.OnSystemButtonPress(SystemButtonType::CaptureButtonLongPressing);
|
window_system.OnSystemButtonPress(SystemButtonType::CaptureButtonLongPressing);
|
||||||
m_capture_button_long_sent = true;
|
m_capture_button_long_sent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,9 +118,8 @@ void ButtonPoller::OnButtonStateChanged() {
|
|||||||
if (!home_button && m_home_button_press_start) {
|
if (!home_button && m_home_button_press_start) {
|
||||||
if(!m_home_button_long_sent) {
|
if(!m_home_button_long_sent) {
|
||||||
const auto duration = ClassifyPressDuration(*m_home_button_press_start);
|
const auto duration = ClassifyPressDuration(*m_home_button_press_start);
|
||||||
m_window_system.OnSystemButtonPress(
|
window_system.OnSystemButtonPress(duration == ButtonPressDuration::ShortPressing
|
||||||
duration == ButtonPressDuration::ShortPressing ? SystemButtonType::HomeButtonShortPressing
|
? SystemButtonType::HomeButtonShortPressing : SystemButtonType::HomeButtonLongPressing);
|
||||||
: SystemButtonType::HomeButtonLongPressing);
|
|
||||||
}
|
}
|
||||||
m_home_button_press_start = std::nullopt;
|
m_home_button_press_start = std::nullopt;
|
||||||
m_home_button_long_sent = false;
|
m_home_button_long_sent = false;
|
||||||
@@ -117,9 +127,8 @@ void ButtonPoller::OnButtonStateChanged() {
|
|||||||
if (!capture_button && m_capture_button_press_start) {
|
if (!capture_button && m_capture_button_press_start) {
|
||||||
if (!m_capture_button_long_sent) {
|
if (!m_capture_button_long_sent) {
|
||||||
const auto duration = ClassifyPressDuration(*m_capture_button_press_start);
|
const auto duration = ClassifyPressDuration(*m_capture_button_press_start);
|
||||||
m_window_system.OnSystemButtonPress(
|
window_system.OnSystemButtonPress(duration == ButtonPressDuration::ShortPressing
|
||||||
duration == ButtonPressDuration::ShortPressing ? SystemButtonType::CaptureButtonShortPressing
|
? SystemButtonType::CaptureButtonShortPressing : SystemButtonType::CaptureButtonLongPressing);
|
||||||
: SystemButtonType::CaptureButtonLongPressing);
|
|
||||||
}
|
}
|
||||||
m_capture_button_press_start = std::nullopt;
|
m_capture_button_press_start = std::nullopt;
|
||||||
m_capture_button_long_sent = false;
|
m_capture_button_long_sent = false;
|
||||||
@@ -130,16 +139,4 @@ void ButtonPoller::OnButtonStateChanged() {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonPoller::ThreadLoop() {
|
|
||||||
using namespace std::chrono_literals;
|
|
||||||
std::unique_lock lk{m_mutex};
|
|
||||||
while (!m_stop) {
|
|
||||||
m_cv.wait_for(lk, 50ms);
|
|
||||||
if (m_stop) break;
|
|
||||||
lk.unlock();
|
|
||||||
OnButtonStateChanged();
|
|
||||||
lk.lock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Service::AM
|
} // namespace Service::AM
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
@@ -30,31 +30,23 @@ class ButtonPoller {
|
|||||||
public:
|
public:
|
||||||
explicit ButtonPoller(Core::System& system, WindowSystem& window_system);
|
explicit ButtonPoller(Core::System& system, WindowSystem& window_system);
|
||||||
~ButtonPoller();
|
~ButtonPoller();
|
||||||
|
void OnButtonStateChanged(WindowSystem& window_system);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnButtonStateChanged();
|
std::mutex m_mutex;
|
||||||
void ThreadLoop();
|
std::condition_variable m_cv;
|
||||||
|
std::jthread m_thread;
|
||||||
private:
|
|
||||||
WindowSystem& m_window_system;
|
|
||||||
|
|
||||||
Core::HID::EmulatedController* m_handheld{};
|
|
||||||
int m_handheld_key{};
|
|
||||||
Core::HID::EmulatedController* m_player1{};
|
|
||||||
int m_player1_key{};
|
|
||||||
|
|
||||||
std::optional<std::chrono::steady_clock::time_point> m_home_button_press_start{};
|
std::optional<std::chrono::steady_clock::time_point> m_home_button_press_start{};
|
||||||
std::optional<std::chrono::steady_clock::time_point> m_capture_button_press_start{};
|
std::optional<std::chrono::steady_clock::time_point> m_capture_button_press_start{};
|
||||||
std::optional<std::chrono::steady_clock::time_point> m_power_button_press_start{};
|
std::optional<std::chrono::steady_clock::time_point> m_power_button_press_start{};
|
||||||
|
|
||||||
bool m_home_button_long_sent{};
|
Core::HID::EmulatedController* m_handheld{};
|
||||||
bool m_capture_button_long_sent{};
|
Core::HID::EmulatedController* m_player1{};
|
||||||
bool m_power_button_long_sent{};
|
int32_t m_handheld_key{};
|
||||||
|
int32_t m_player1_key{};
|
||||||
std::thread m_thread;
|
bool m_home_button_long_sent : 1 = false;
|
||||||
std::atomic<bool> m_stop{false};
|
bool m_capture_button_long_sent : 1 = false;
|
||||||
std::condition_variable m_cv;
|
bool m_power_button_long_sent : 1 = false;
|
||||||
std::mutex m_mutex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::AM
|
} // namespace Service::AM
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -15,12 +18,24 @@ enum class UserDataTag : u32 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EventObserver::EventObserver(Core::System& system, WindowSystem& window_system)
|
EventObserver::EventObserver(Core::System& system, WindowSystem& window_system)
|
||||||
: m_system(system), m_context(system, "am:EventObserver"), m_window_system(window_system),
|
: m_system(system), m_context(system, "am:EventObserver")
|
||||||
m_wakeup_event(m_context), m_wakeup_holder(m_wakeup_event.GetHandle()) {
|
, m_window_system(window_system)
|
||||||
|
, m_wakeup_event(m_context)
|
||||||
|
, m_wakeup_holder(m_wakeup_event.GetHandle())
|
||||||
|
{
|
||||||
m_window_system.SetEventObserver(this);
|
m_window_system.SetEventObserver(this);
|
||||||
m_wakeup_holder.SetUserData(static_cast<uintptr_t>(UserDataTag::WakeupEvent));
|
m_wakeup_holder.SetUserData(static_cast<uintptr_t>(UserDataTag::WakeupEvent));
|
||||||
m_wakeup_holder.LinkToMultiWait(std::addressof(m_multi_wait));
|
m_wakeup_holder.LinkToMultiWait(std::addressof(m_multi_wait));
|
||||||
m_thread = std::thread([&] { this->ThreadFunc(); });
|
m_thread = std::thread([this] {
|
||||||
|
Common::SetCurrentThreadName("am:EventObserver");
|
||||||
|
while (true) {
|
||||||
|
auto* signaled_holder = this->WaitSignaled();
|
||||||
|
if (!signaled_holder) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this->Process(signaled_holder);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
EventObserver::~EventObserver() {
|
EventObserver::~EventObserver() {
|
||||||
@@ -146,17 +161,4 @@ void EventObserver::DestroyAppletProcessHolderLocked(ProcessHolder* holder) {
|
|||||||
delete holder;
|
delete holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventObserver::ThreadFunc() {
|
|
||||||
Common::SetCurrentThreadName("am:EventObserver");
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
auto* signaled_holder = this->WaitSignaled();
|
|
||||||
if (!signaled_holder) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->Process(signaled_holder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Service::AM
|
} // namespace Service::AM
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -41,9 +44,6 @@ private:
|
|||||||
private:
|
private:
|
||||||
void DestroyAppletProcessHolderLocked(ProcessHolder* holder);
|
void DestroyAppletProcessHolderLocked(ProcessHolder* holder);
|
||||||
|
|
||||||
private:
|
|
||||||
void ThreadFunc();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// System reference and context.
|
// System reference and context.
|
||||||
Core::System& m_system;
|
Core::System& m_system;
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/file_sys/content_archive.h"
|
#include "core/file_sys/content_archive.h"
|
||||||
#include "core/file_sys/nca_metadata.h"
|
#include "core/file_sys/nca_metadata.h"
|
||||||
@@ -16,7 +20,7 @@ namespace Service::AM {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
FileSys::StorageId GetStorageIdForFrontendSlot(
|
[[nodiscard]] FileSys::StorageId GetStorageIdForFrontendSlot(
|
||||||
std::optional<FileSys::ContentProviderUnionSlot> slot) {
|
std::optional<FileSys::ContentProviderUnionSlot> slot) {
|
||||||
if (!slot.has_value()) {
|
if (!slot.has_value()) {
|
||||||
return FileSys::StorageId::None;
|
return FileSys::StorageId::None;
|
||||||
@@ -36,31 +40,23 @@ FileSys::StorageId GetStorageIdForFrontendSlot(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Process> CreateProcessImpl(std::unique_ptr<Loader::AppLoader>& out_loader,
|
[[nodiscard]] inline std::optional<Process> CreateProcessImpl(std::unique_ptr<Loader::AppLoader>& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) {
|
||||||
Loader::ResultStatus& out_load_result,
|
|
||||||
Core::System& system, FileSys::VirtualFile file,
|
|
||||||
u64 program_id, u64 program_index) {
|
|
||||||
// Get the appropriate loader to parse this NCA.
|
// Get the appropriate loader to parse this NCA.
|
||||||
out_loader = Loader::GetLoader(system, file, program_id, program_index);
|
out_loader = Loader::GetLoader(system, file, program_id, program_index);
|
||||||
|
|
||||||
// Ensure we have a loader which can parse the NCA.
|
// Ensure we have a loader which can parse the NCA.
|
||||||
if (!out_loader) {
|
if (out_loader) {
|
||||||
return nullptr;
|
// Try to load the process.
|
||||||
|
auto process = std::make_optional<Process>(system);
|
||||||
|
if (process->Initialize(*out_loader, out_load_result)) {
|
||||||
|
return process;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return std::nullopt;
|
||||||
// Try to load the process.
|
|
||||||
auto process = std::make_unique<Process>(system);
|
|
||||||
if (process->Initialize(*out_loader, out_load_result)) {
|
|
||||||
return process;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
std::unique_ptr<Process> CreateProcess(Core::System& system, u64 program_id,
|
std::optional<Process> CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation) {
|
||||||
u8 minimum_key_generation, u8 maximum_key_generation) {
|
|
||||||
// Attempt to load program NCA.
|
// Attempt to load program NCA.
|
||||||
FileSys::VirtualFile nca_raw{};
|
FileSys::VirtualFile nca_raw{};
|
||||||
|
|
||||||
@@ -70,7 +66,7 @@ std::unique_ptr<Process> CreateProcess(Core::System& system, u64 program_id,
|
|||||||
|
|
||||||
// Ensure we retrieved a program NCA.
|
// Ensure we retrieved a program NCA.
|
||||||
if (!nca_raw) {
|
if (!nca_raw) {
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure we have a suitable version.
|
// Ensure we have a suitable version.
|
||||||
@@ -79,9 +75,8 @@ std::unique_ptr<Process> CreateProcess(Core::System& system, u64 program_id,
|
|||||||
if (nca.GetStatus() == Loader::ResultStatus::Success &&
|
if (nca.GetStatus() == Loader::ResultStatus::Success &&
|
||||||
(nca.GetKeyGeneration() < minimum_key_generation ||
|
(nca.GetKeyGeneration() < minimum_key_generation ||
|
||||||
nca.GetKeyGeneration() > maximum_key_generation)) {
|
nca.GetKeyGeneration() > maximum_key_generation)) {
|
||||||
LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id,
|
LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id, nca.GetKeyGeneration());
|
||||||
nca.GetKeyGeneration());
|
return std::nullopt;
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,42 +85,32 @@ std::unique_ptr<Process> CreateProcess(Core::System& system, u64 program_id,
|
|||||||
return CreateProcessImpl(loader, status, system, nca_raw, program_id, 0);
|
return CreateProcessImpl(loader, status, system, nca_raw, program_id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Process> CreateApplicationProcess(std::vector<u8>& out_control,
|
std::optional<Process> CreateApplicationProcess(std::vector<u8>& out_control, std::unique_ptr<Loader::AppLoader>& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) {
|
||||||
std::unique_ptr<Loader::AppLoader>& out_loader,
|
if (auto process = CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); process) {
|
||||||
Loader::ResultStatus& out_load_result,
|
FileSys::NACP nacp;
|
||||||
Core::System& system, FileSys::VirtualFile file,
|
if (out_loader->ReadControlData(nacp) == Loader::ResultStatus::Success) {
|
||||||
u64 program_id, u64 program_index) {
|
out_control = nacp.GetRawBytes();
|
||||||
auto process =
|
} else {
|
||||||
CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index);
|
out_control.resize(sizeof(FileSys::RawNACP));
|
||||||
if (!process) {
|
std::fill(out_control.begin(), out_control.end(), (u8) 0);
|
||||||
return nullptr;
|
}
|
||||||
|
|
||||||
|
auto& storage = system.GetContentProviderUnion();
|
||||||
|
Service::Glue::ApplicationLaunchProperty launch{};
|
||||||
|
launch.title_id = process->GetProgramId();
|
||||||
|
|
||||||
|
FileSys::PatchManager pm{launch.title_id, system.GetFileSystemController(), storage};
|
||||||
|
launch.version = pm.GetGameVersion().value_or(0);
|
||||||
|
|
||||||
|
// TODO(DarkLordZach): When FSController/Game Card Support is added, if
|
||||||
|
// current_process_game_card use correct StorageId
|
||||||
|
launch.base_game_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program));
|
||||||
|
launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program));
|
||||||
|
|
||||||
|
system.GetARPManager().Register(launch.title_id, launch, out_control);
|
||||||
|
return process;
|
||||||
}
|
}
|
||||||
|
return std::nullopt;
|
||||||
FileSys::NACP nacp;
|
|
||||||
if (out_loader->ReadControlData(nacp) == Loader::ResultStatus::Success) {
|
|
||||||
out_control = nacp.GetRawBytes();
|
|
||||||
} else {
|
|
||||||
out_control.resize(sizeof(FileSys::RawNACP));
|
|
||||||
std::fill(out_control.begin(), out_control.end(), (u8) 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& storage = system.GetContentProviderUnion();
|
|
||||||
Service::Glue::ApplicationLaunchProperty launch{};
|
|
||||||
launch.title_id = process->GetProgramId();
|
|
||||||
|
|
||||||
FileSys::PatchManager pm{launch.title_id, system.GetFileSystemController(), storage};
|
|
||||||
launch.version = pm.GetGameVersion().value_or(0);
|
|
||||||
|
|
||||||
// TODO(DarkLordZach): When FSController/Game Card Support is added, if
|
|
||||||
// current_process_game_card use correct StorageId
|
|
||||||
launch.base_game_storage_id = GetStorageIdForFrontendSlot(
|
|
||||||
storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program));
|
|
||||||
launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(
|
|
||||||
FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program));
|
|
||||||
|
|
||||||
system.GetARPManager().Register(launch.title_id, launch, out_control);
|
|
||||||
|
|
||||||
return process;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::AM
|
} // namespace Service::AM
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -24,12 +27,7 @@ class Process;
|
|||||||
|
|
||||||
namespace Service::AM {
|
namespace Service::AM {
|
||||||
|
|
||||||
std::unique_ptr<Process> CreateProcess(Core::System& system, u64 program_id,
|
std::optional<Process> CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation);
|
||||||
u8 minimum_key_generation, u8 maximum_key_generation);
|
std::optional<Process> CreateApplicationProcess(std::vector<u8>& out_control, std::unique_ptr<Loader::AppLoader>& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index);
|
||||||
std::unique_ptr<Process> CreateApplicationProcess(std::vector<u8>& out_control,
|
|
||||||
std::unique_ptr<Loader::AppLoader>& out_loader,
|
|
||||||
Loader::ResultStatus& out_load_result,
|
|
||||||
Core::System& system, FileSys::VirtualFile file,
|
|
||||||
u64 program_id, u64 program_index);
|
|
||||||
|
|
||||||
} // namespace Service::AM
|
} // namespace Service::AM
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
@@ -21,8 +21,7 @@ namespace Service::AM {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Result CreateGuestApplication(SharedPointer<IApplicationAccessor>* out_application_accessor,
|
Result CreateGuestApplication(SharedPointer<IApplicationAccessor>* out_application_accessor, Core::System& system, WindowSystem& window_system, u64 program_id) {
|
||||||
Core::System& system, WindowSystem& window_system, u64 program_id) {
|
|
||||||
FileSys::VirtualFile nca_raw{};
|
FileSys::VirtualFile nca_raw{};
|
||||||
|
|
||||||
// Get the program NCA from storage.
|
// Get the program NCA from storage.
|
||||||
@@ -35,11 +34,10 @@ Result CreateGuestApplication(SharedPointer<IApplicationAccessor>* out_applicati
|
|||||||
std::vector<u8> control;
|
std::vector<u8> control;
|
||||||
std::unique_ptr<Loader::AppLoader> loader;
|
std::unique_ptr<Loader::AppLoader> loader;
|
||||||
Loader::ResultStatus result;
|
Loader::ResultStatus result;
|
||||||
auto process =
|
auto process = CreateApplicationProcess(control, loader, result, system, nca_raw, program_id, 0);
|
||||||
CreateApplicationProcess(control, loader, result, system, nca_raw, program_id, 0);
|
R_UNLESS(process != std::nullopt, ResultUnknown);
|
||||||
R_UNLESS(process != nullptr, ResultUnknown);
|
|
||||||
|
|
||||||
const auto applet = std::make_shared<Applet>(system, std::move(process), true);
|
const auto applet = std::make_shared<Applet>(system, std::make_unique<Service::Process>(*std::move(process)), true);
|
||||||
applet->program_id = program_id;
|
applet->program_id = program_id;
|
||||||
applet->applet_id = AppletId::Application;
|
applet->applet_id = AppletId::Application;
|
||||||
applet->type = AppletType::Application;
|
applet->type = AppletType::Application;
|
||||||
@@ -47,8 +45,7 @@ Result CreateGuestApplication(SharedPointer<IApplicationAccessor>* out_applicati
|
|||||||
|
|
||||||
window_system.TrackApplet(applet, true);
|
window_system.TrackApplet(applet, true);
|
||||||
|
|
||||||
*out_application_accessor =
|
*out_application_accessor = std::make_shared<IApplicationAccessor>(system, applet, window_system);
|
||||||
std::make_shared<IApplicationAccessor>(system, applet, window_system);
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,12 +87,10 @@ Result IApplicationCreator::CreateSystemApplication(
|
|||||||
|
|
||||||
std::vector<u8> control;
|
std::vector<u8> control;
|
||||||
std::unique_ptr<Loader::AppLoader> loader;
|
std::unique_ptr<Loader::AppLoader> loader;
|
||||||
|
auto process = CreateProcess(system, application_id, 1, 21);
|
||||||
|
R_UNLESS(process != std::nullopt, ResultUnknown);
|
||||||
|
|
||||||
auto process =
|
const auto applet = std::make_shared<Applet>(system, std::make_unique<Service::Process>(*std::move(process)), true);
|
||||||
CreateProcess(system, application_id, 1, 21);
|
|
||||||
R_UNLESS(process != nullptr, ResultUnknown);
|
|
||||||
|
|
||||||
const auto applet = std::make_shared<Applet>(system, std::move(process), true);
|
|
||||||
applet->program_id = application_id;
|
applet->program_id = application_id;
|
||||||
applet->applet_id = AppletId::Starter;
|
applet->applet_id = AppletId::Starter;
|
||||||
applet->type = AppletType::LibraryApplet;
|
applet->type = AppletType::LibraryApplet;
|
||||||
@@ -103,8 +98,7 @@ Result IApplicationCreator::CreateSystemApplication(
|
|||||||
|
|
||||||
m_window_system.TrackApplet(applet, true);
|
m_window_system.TrackApplet(applet, true);
|
||||||
|
|
||||||
*out_application_accessor =
|
*out_application_accessor = std::make_shared<IApplicationAccessor>(system, applet, m_window_system);
|
||||||
std::make_shared<IApplicationAccessor>(system, applet, m_window_system);
|
|
||||||
Core::LaunchTimestampCache::SaveLaunchTimestamp(application_id);
|
Core::LaunchTimestampCache::SaveLaunchTimestamp(application_id);
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
@@ -121,26 +121,23 @@ std::shared_ptr<ILibraryAppletAccessor> CreateGuestApplet(Core::System& system,
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto process = CreateProcess(system, program_id, Firmware1400, Firmware2100);
|
auto process = CreateProcess(system, program_id, Firmware1400, Firmware2100);
|
||||||
if (!process) {
|
if (process) {
|
||||||
// Couldn't initialize the guest process
|
const auto applet = std::make_shared<Applet>(system, std::make_unique<Service::Process>(*std::move(process)), false);
|
||||||
return {};
|
applet->program_id = program_id;
|
||||||
|
applet->applet_id = applet_id;
|
||||||
|
applet->type = AppletType::LibraryApplet;
|
||||||
|
applet->library_applet_mode = mode;
|
||||||
|
applet->window_visible = mode != LibraryAppletMode::AllForegroundInitiallyHidden;
|
||||||
|
|
||||||
|
auto broker = std::make_shared<AppletDataBroker>(system);
|
||||||
|
applet->caller_applet = caller_applet;
|
||||||
|
applet->caller_applet_broker = broker;
|
||||||
|
caller_applet->child_applets.push_back(applet);
|
||||||
|
window_system.TrackApplet(applet, false);
|
||||||
|
return std::make_shared<ILibraryAppletAccessor>(system, broker, applet);
|
||||||
}
|
}
|
||||||
|
// Couldn't initialize the guest process
|
||||||
const auto applet = std::make_shared<Applet>(system, std::move(process), false);
|
return {};
|
||||||
applet->program_id = program_id;
|
|
||||||
applet->applet_id = applet_id;
|
|
||||||
applet->type = AppletType::LibraryApplet;
|
|
||||||
applet->library_applet_mode = mode;
|
|
||||||
applet->window_visible = mode != LibraryAppletMode::AllForegroundInitiallyHidden;
|
|
||||||
|
|
||||||
auto broker = std::make_shared<AppletDataBroker>(system);
|
|
||||||
applet->caller_applet = caller_applet;
|
|
||||||
applet->caller_applet_broker = broker;
|
|
||||||
caller_applet->child_applets.push_back(applet);
|
|
||||||
|
|
||||||
window_system.TrackApplet(applet, false);
|
|
||||||
|
|
||||||
return std::make_shared<ILibraryAppletAccessor>(system, broker, applet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ILibraryAppletAccessor> CreateFrontendApplet(Core::System& system,
|
std::shared_ptr<ILibraryAppletAccessor> CreateFrontendApplet(Core::System& system,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
@@ -14,7 +14,9 @@ namespace Service::Audio {
|
|||||||
using namespace AudioCore::AudioOut;
|
using namespace AudioCore::AudioOut;
|
||||||
|
|
||||||
IAudioOutManager::IAudioOutManager(Core::System& system_)
|
IAudioOutManager::IAudioOutManager(Core::System& system_)
|
||||||
: ServiceFramework{system_, "audout:u"}, impl{std::make_unique<Manager>(system_)} {
|
: ServiceFramework{system_, "audout:u"}
|
||||||
|
, impl(system_)
|
||||||
|
{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, D<&IAudioOutManager::ListAudioOuts>, "ListAudioOuts"},
|
{0, D<&IAudioOutManager::ListAudioOuts>, "ListAudioOuts"},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
@@ -43,7 +43,7 @@ private:
|
|||||||
AudioCore::AudioOut::AudioOutParameter parameter,
|
AudioCore::AudioOut::AudioOutParameter parameter,
|
||||||
InCopyHandle<Kernel::KProcess> process_handle, ClientAppletResourceUserId aruid);
|
InCopyHandle<Kernel::KProcess> process_handle, ClientAppletResourceUserId aruid);
|
||||||
|
|
||||||
std::unique_ptr<AudioCore::AudioOut::Manager> impl;
|
std::optional<AudioCore::AudioOut::Manager> impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::Audio
|
} // namespace Service::Audio
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -15,7 +18,9 @@ namespace Service::Audio {
|
|||||||
using namespace AudioCore::Renderer;
|
using namespace AudioCore::Renderer;
|
||||||
|
|
||||||
IAudioRendererManager::IAudioRendererManager(Core::System& system_)
|
IAudioRendererManager::IAudioRendererManager(Core::System& system_)
|
||||||
: ServiceFramework{system_, "audren:u"}, impl{std::make_unique<Manager>(system_)} {
|
: ServiceFramework{system_, "audren:u"}
|
||||||
|
, impl(system_)
|
||||||
|
{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, D<&IAudioRendererManager::OpenAudioRenderer>, "OpenAudioRenderer"},
|
{0, D<&IAudioRendererManager::OpenAudioRenderer>, "OpenAudioRenderer"},
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -30,7 +33,7 @@ private:
|
|||||||
Result GetAudioDeviceServiceWithRevisionInfo(Out<SharedPointer<IAudioDevice>> out_audio_device,
|
Result GetAudioDeviceServiceWithRevisionInfo(Out<SharedPointer<IAudioDevice>> out_audio_device,
|
||||||
u32 revision, ClientAppletResourceUserId aruid);
|
u32 revision, ClientAppletResourceUserId aruid);
|
||||||
|
|
||||||
std::unique_ptr<AudioCore::Renderer::Manager> impl;
|
std::optional<AudioCore::Renderer::Manager> impl;
|
||||||
u32 num_audio_devices{0};
|
u32 num_audio_devices{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -10,14 +13,6 @@
|
|||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
|
|
||||||
Process::Process(Core::System& system)
|
|
||||||
: m_system(system), m_process(), m_main_thread_priority(), m_main_thread_stack_size(),
|
|
||||||
m_process_started() {}
|
|
||||||
|
|
||||||
Process::~Process() {
|
|
||||||
this->Finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Process::Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result) {
|
bool Process::Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result) {
|
||||||
// First, ensure we are not holding another process.
|
// First, ensure we are not holding another process.
|
||||||
this->Finalize();
|
this->Finalize();
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -22,8 +25,8 @@ namespace Service {
|
|||||||
|
|
||||||
class Process {
|
class Process {
|
||||||
public:
|
public:
|
||||||
explicit Process(Core::System& system);
|
inline explicit Process(Core::System& system) noexcept : m_system(system) {}
|
||||||
~Process();
|
inline ~Process() { this->Finalize(); }
|
||||||
|
|
||||||
bool Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result);
|
bool Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result);
|
||||||
void Finalize();
|
void Finalize();
|
||||||
@@ -50,8 +53,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
Core::System& m_system;
|
Core::System& m_system;
|
||||||
Kernel::KProcess* m_process{};
|
Kernel::KProcess* m_process{};
|
||||||
s32 m_main_thread_priority{};
|
|
||||||
u64 m_main_thread_stack_size{};
|
u64 m_main_thread_stack_size{};
|
||||||
|
s32 m_main_thread_priority{};
|
||||||
bool m_process_started{};
|
bool m_process_started{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "common/logging.h"
|
#include "common/logging.h"
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
|
#include "common/thread.h"
|
||||||
#include "input_common/drivers/udp_client.h"
|
#include "input_common/drivers/udp_client.h"
|
||||||
#include "input_common/helpers/udp_protocol.h"
|
#include "input_common/helpers/udp_protocol.h"
|
||||||
|
|
||||||
@@ -135,6 +136,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void SocketLoop(Socket* socket) {
|
static void SocketLoop(Socket* socket) {
|
||||||
|
Common::SetCurrentThreadName("cemuhookWorker");
|
||||||
socket->StartReceive();
|
socket->StartReceive();
|
||||||
socket->StartSend(Socket::clock::now());
|
socket->StartSend(Socket::clock::now());
|
||||||
socket->Loop();
|
socket->Loop();
|
||||||
@@ -330,9 +332,11 @@ void UDPClient::OnPadData(Response::PadData data, std::size_t client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) {
|
void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) {
|
||||||
SocketCallback callback{[this](Response::Version version) { OnVersion(version); },
|
SocketCallback callback{
|
||||||
[this](Response::PortInfo info) { OnPortInfo(info); },
|
[this](Response::Version version) { OnVersion(version); },
|
||||||
[this, client](Response::PadData data) { OnPadData(data, client); }};
|
[this](Response::PortInfo info) { OnPortInfo(info); },
|
||||||
|
[this, client](Response::PadData data) { OnPadData(data, client); }
|
||||||
|
};
|
||||||
LOG_INFO(Input, "Starting communication with UDP input server on {}:{}", host, port);
|
LOG_INFO(Input, "Starting communication with UDP input server on {}:{}", host, port);
|
||||||
clients[client].uuid = GetHostUUID(host);
|
clients[client].uuid = GetHostUUID(host);
|
||||||
clients[client].host = host;
|
clients[client].host = host;
|
||||||
@@ -570,9 +574,7 @@ bool UDPClient::IsStickInverted(const Common::ParamPackage& params) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCommunication(const std::string& host, u16 port,
|
void TestCommunication(const std::string& host, u16 port, const std::function<void()>& success_callback, const std::function<void()>& failure_callback) {
|
||||||
const std::function<void()>& success_callback,
|
|
||||||
const std::function<void()>& failure_callback) {
|
|
||||||
std::thread([=] {
|
std::thread([=] {
|
||||||
Common::Event success_event;
|
Common::Event success_event;
|
||||||
SocketCallback callback{
|
SocketCallback callback{
|
||||||
@@ -605,40 +607,38 @@ CalibrationConfigurationJob::CalibrationConfigurationJob(
|
|||||||
u16 max_y{};
|
u16 max_y{};
|
||||||
|
|
||||||
Status current_status{Status::Initialized};
|
Status current_status{Status::Initialized};
|
||||||
SocketCallback callback{[](Response::Version) {}, [](Response::PortInfo) {},
|
SocketCallback callback{[](Response::Version) {}, [](Response::PortInfo) {}, [&](Response::PadData data) {
|
||||||
[&](Response::PadData data) {
|
constexpr u16 CALIBRATION_THRESHOLD = 100;
|
||||||
constexpr u16 CALIBRATION_THRESHOLD = 100;
|
|
||||||
|
|
||||||
if (current_status == Status::Initialized) {
|
if (current_status == Status::Initialized) {
|
||||||
// Receiving data means the communication is ready now
|
// Receiving data means the communication is ready now
|
||||||
current_status = Status::Ready;
|
current_status = Status::Ready;
|
||||||
status_callback(current_status);
|
status_callback(current_status);
|
||||||
}
|
}
|
||||||
if (data.touch[0].is_active == 0) {
|
if (data.touch[0].is_active == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG_DEBUG(Input, "Current touch: {} {}", data.touch[0].x,
|
LOG_DEBUG(Input, "Current touch: {} {}", data.touch[0].x, data.touch[0].y);
|
||||||
data.touch[0].y);
|
min_x = (std::min)(min_x, u16(data.touch[0].x));
|
||||||
min_x = (std::min)(min_x, static_cast<u16>(data.touch[0].x));
|
min_y = (std::min)(min_y, u16(data.touch[0].y));
|
||||||
min_y = (std::min)(min_y, static_cast<u16>(data.touch[0].y));
|
if (current_status == Status::Ready) {
|
||||||
if (current_status == Status::Ready) {
|
// First touch - min data (min_x/min_y)
|
||||||
// First touch - min data (min_x/min_y)
|
current_status = Status::Stage1Completed;
|
||||||
current_status = Status::Stage1Completed;
|
status_callback(current_status);
|
||||||
status_callback(current_status);
|
}
|
||||||
}
|
if (data.touch[0].x - min_x > CALIBRATION_THRESHOLD &&
|
||||||
if (data.touch[0].x - min_x > CALIBRATION_THRESHOLD &&
|
data.touch[0].y - min_y > CALIBRATION_THRESHOLD) {
|
||||||
data.touch[0].y - min_y > CALIBRATION_THRESHOLD) {
|
// Set the current position as max value and finishes
|
||||||
// Set the current position as max value and finishes
|
// configuration
|
||||||
// configuration
|
max_x = data.touch[0].x;
|
||||||
max_x = data.touch[0].x;
|
max_y = data.touch[0].y;
|
||||||
max_y = data.touch[0].y;
|
current_status = Status::Completed;
|
||||||
current_status = Status::Completed;
|
data_callback(min_x, min_y, max_x, max_y);
|
||||||
data_callback(min_x, min_y, max_x, max_y);
|
status_callback(current_status);
|
||||||
status_callback(current_status);
|
|
||||||
|
|
||||||
complete_event.Set();
|
complete_event.Set();
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
Socket socket{host, port, std::move(callback)};
|
Socket socket{host, port, std::move(callback)};
|
||||||
std::thread worker_thread{SocketLoop, &socket};
|
std::thread worker_thread{SocketLoop, &socket};
|
||||||
complete_event.Wait();
|
complete_event.Wait();
|
||||||
|
|||||||
@@ -126,16 +126,14 @@ public:
|
|||||||
current_query = nullptr;
|
current_query = nullptr;
|
||||||
amend_value = 0;
|
amend_value = 0;
|
||||||
accumulation_value = 0;
|
accumulation_value = 0;
|
||||||
queries_prefix_scan_pass = std::make_unique<QueriesPrefixScanPass>(
|
queries_prefix_scan_pass.emplace(device, scheduler, descriptor_pool, compute_pass_descriptor_queue);
|
||||||
device, scheduler, descriptor_pool, compute_pass_descriptor_queue);
|
|
||||||
|
|
||||||
const VkBufferCreateInfo buffer_ci = {
|
const VkBufferCreateInfo buffer_ci = {
|
||||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.size = 8,
|
.size = 8,
|
||||||
.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
|
.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
|
||||||
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
|
|
||||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||||
.queueFamilyIndexCount = 0,
|
.queueFamilyIndexCount = 0,
|
||||||
.pQueueFamilyIndices = nullptr,
|
.pQueueFamilyIndices = nullptr,
|
||||||
@@ -592,8 +590,7 @@ private:
|
|||||||
VideoCommon::HostQueryBase* current_query;
|
VideoCommon::HostQueryBase* current_query;
|
||||||
bool has_started{};
|
bool has_started{};
|
||||||
std::mutex flush_guard;
|
std::mutex flush_guard;
|
||||||
|
std::optional<QueriesPrefixScanPass> queries_prefix_scan_pass;
|
||||||
std::unique_ptr<QueriesPrefixScanPass> queries_prefix_scan_pass;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Transform feedback queries
|
// Transform feedback queries
|
||||||
@@ -1176,35 +1173,21 @@ private:
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct QueryCacheRuntimeImpl {
|
struct QueryCacheRuntimeImpl {
|
||||||
QueryCacheRuntimeImpl(QueryCacheRuntime& runtime, VideoCore::RasterizerInterface* rasterizer_,
|
QueryCacheRuntimeImpl(QueryCacheRuntime& runtime, VideoCore::RasterizerInterface* rasterizer_, Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool, TextureCache& texture_cache_)
|
||||||
Tegra::MaxwellDeviceMemoryManager& device_memory_,
|
: rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_}
|
||||||
Vulkan::BufferCache& buffer_cache_, const Device& device_,
|
, device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}
|
||||||
const MemoryAllocator& memory_allocator_, Scheduler& scheduler_,
|
, staging_pool{staging_pool_}, guest_streamer(0, runtime)
|
||||||
StagingBufferPool& staging_pool_,
|
, sample_streamer(size_t(QueryType::ZPassPixelCount64), runtime, rasterizer, texture_cache_, device, scheduler, memory_allocator, compute_pass_descriptor_queue, descriptor_pool)
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue,
|
, tfb_streamer(size_t(QueryType::StreamingByteCount), runtime, device, scheduler, memory_allocator, staging_pool)
|
||||||
DescriptorPool& descriptor_pool, TextureCache& texture_cache_)
|
, primitives_succeeded_streamer(size_t(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer, device_memory_)
|
||||||
: rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_},
|
, primitives_needed_minus_succeeded_streamer(size_t(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u)
|
||||||
device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_},
|
, hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} {
|
||||||
staging_pool{staging_pool_}, guest_streamer(0, runtime),
|
|
||||||
sample_streamer(static_cast<size_t>(QueryType::ZPassPixelCount64), runtime, rasterizer,
|
|
||||||
texture_cache_, device, scheduler, memory_allocator,
|
|
||||||
compute_pass_descriptor_queue, descriptor_pool),
|
|
||||||
tfb_streamer(static_cast<size_t>(QueryType::StreamingByteCount), runtime, device,
|
|
||||||
scheduler, memory_allocator, staging_pool),
|
|
||||||
primitives_succeeded_streamer(
|
|
||||||
static_cast<size_t>(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer,
|
|
||||||
device_memory_),
|
|
||||||
primitives_needed_minus_succeeded_streamer(
|
|
||||||
static_cast<size_t>(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u),
|
|
||||||
hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} {
|
|
||||||
|
|
||||||
hcr_setup.sType = VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT;
|
hcr_setup.sType = VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT;
|
||||||
hcr_setup.pNext = nullptr;
|
hcr_setup.pNext = nullptr;
|
||||||
hcr_setup.flags = 0;
|
hcr_setup.flags = 0;
|
||||||
|
|
||||||
conditional_resolve_pass = std::make_unique<ConditionalRenderingResolvePass>(
|
conditional_resolve_pass.emplace(device, scheduler, descriptor_pool, compute_pass_descriptor_queue);
|
||||||
device, scheduler, descriptor_pool, compute_pass_descriptor_queue);
|
|
||||||
|
|
||||||
const VkBufferCreateInfo buffer_ci = {
|
const VkBufferCreateInfo buffer_ci = {
|
||||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
@@ -1241,7 +1224,7 @@ struct QueryCacheRuntimeImpl {
|
|||||||
std::vector<std::vector<VkBufferCopy>> copies_setup;
|
std::vector<std::vector<VkBufferCopy>> copies_setup;
|
||||||
|
|
||||||
// Host conditional rendering data
|
// Host conditional rendering data
|
||||||
std::unique_ptr<ConditionalRenderingResolvePass> conditional_resolve_pass;
|
std::optional<ConditionalRenderingResolvePass> conditional_resolve_pass;
|
||||||
vk::Buffer hcr_resolve_buffer;
|
vk::Buffer hcr_resolve_buffer;
|
||||||
VkConditionalRenderingBeginInfoEXT hcr_setup;
|
VkConditionalRenderingBeginInfoEXT hcr_setup;
|
||||||
VkBuffer hcr_buffer;
|
VkBuffer hcr_buffer;
|
||||||
@@ -1253,13 +1236,7 @@ struct QueryCacheRuntimeImpl {
|
|||||||
Maxwell3D* maxwell3d;
|
Maxwell3D* maxwell3d;
|
||||||
};
|
};
|
||||||
|
|
||||||
QueryCacheRuntime::QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer,
|
QueryCacheRuntime::QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer, Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool, TextureCache& texture_cache_) {
|
||||||
Tegra::MaxwellDeviceMemoryManager& device_memory_,
|
|
||||||
Vulkan::BufferCache& buffer_cache_, const Device& device_,
|
|
||||||
const MemoryAllocator& memory_allocator_,
|
|
||||||
Scheduler& scheduler_, StagingBufferPool& staging_pool_,
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue,
|
|
||||||
DescriptorPool& descriptor_pool, TextureCache& texture_cache_) {
|
|
||||||
impl = std::make_unique<QueryCacheRuntimeImpl>(
|
impl = std::make_unique<QueryCacheRuntimeImpl>(
|
||||||
*this, rasterizer, device_memory_, buffer_cache_, device_, memory_allocator_, scheduler_,
|
*this, rasterizer, device_memory_, buffer_cache_, device_, memory_allocator_, scheduler_,
|
||||||
staging_pool_, compute_pass_descriptor_queue, descriptor_pool, texture_cache_);
|
staging_pool_, compute_pass_descriptor_queue, descriptor_pool, texture_cache_);
|
||||||
@@ -1484,13 +1461,11 @@ void QueryCacheRuntime::Barriers(bool is_prebarrier) {
|
|||||||
impl->scheduler.RequestOutsideRenderPassOperationContext();
|
impl->scheduler.RequestOutsideRenderPassOperationContext();
|
||||||
if (is_prebarrier) {
|
if (is_prebarrier) {
|
||||||
impl->scheduler.Record([](vk::CommandBuffer cmdbuf) {
|
impl->scheduler.Record([](vk::CommandBuffer cmdbuf) {
|
||||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, READ_BARRIER);
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, READ_BARRIER);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
impl->scheduler.Record([](vk::CommandBuffer cmdbuf) {
|
impl->scheduler.Record([](vk::CommandBuffer cmdbuf) {
|
||||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, WRITE_BARRIER);
|
||||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, WRITE_BARRIER);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1583,8 +1558,7 @@ void QueryCacheRuntime::SyncValues(std::span<SyncValuesType> values, VkBuffer ba
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl->scheduler.RequestOutsideRenderPassOperationContext();
|
impl->scheduler.RequestOutsideRenderPassOperationContext();
|
||||||
impl->scheduler.Record([src_buffer, dst_buffers = std::move(impl->buffers_to_upload_to),
|
impl->scheduler.Record([src_buffer, dst_buffers = std::move(impl->buffers_to_upload_to), vk_copies = std::move(impl->copies_setup)](vk::CommandBuffer cmdbuf) {
|
||||||
vk_copies = std::move(impl->copies_setup)](vk::CommandBuffer cmdbuf) {
|
|
||||||
size_t size = dst_buffers.size();
|
size_t size = dst_buffers.size();
|
||||||
for (size_t i = 0; i < size; i++) {
|
for (size_t i = 0; i < size; i++) {
|
||||||
cmdbuf.CopyBuffer(src_buffer, dst_buffers[i].first, vk_copies[i]);
|
cmdbuf.CopyBuffer(src_buffer, dst_buffers[i].first, vk_copies[i]);
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <variant>
|
||||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
@@ -12,20 +15,15 @@ namespace Vulkan {
|
|||||||
class Device;
|
class Device;
|
||||||
class Scheduler;
|
class Scheduler;
|
||||||
|
|
||||||
struct DescriptorUpdateEntry {
|
union DescriptorUpdateEntry {
|
||||||
struct Empty {};
|
|
||||||
|
|
||||||
DescriptorUpdateEntry() = default;
|
DescriptorUpdateEntry() = default;
|
||||||
DescriptorUpdateEntry(VkDescriptorImageInfo image_) : image{image_} {}
|
DescriptorUpdateEntry(VkDescriptorImageInfo image_) : image{image_} {}
|
||||||
DescriptorUpdateEntry(VkDescriptorBufferInfo buffer_) : buffer{buffer_} {}
|
DescriptorUpdateEntry(VkDescriptorBufferInfo buffer_) : buffer{buffer_} {}
|
||||||
DescriptorUpdateEntry(VkBufferView texel_buffer_) : texel_buffer{texel_buffer_} {}
|
DescriptorUpdateEntry(VkBufferView texel_buffer_) : texel_buffer{texel_buffer_} {}
|
||||||
|
std::monostate empty{};
|
||||||
union {
|
VkDescriptorImageInfo image;
|
||||||
Empty empty{};
|
VkDescriptorBufferInfo buffer;
|
||||||
VkDescriptorImageInfo image;
|
VkBufferView texel_buffer;
|
||||||
VkDescriptorBufferInfo buffer;
|
|
||||||
VkBufferView texel_buffer;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class UpdateDescriptorQueue final {
|
class UpdateDescriptorQueue final {
|
||||||
|
|||||||
Reference in New Issue
Block a user