mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-29 18:08:08 +00:00
54cd5fb8eb
- [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- - Dynamic shader cache reloading capability for qlaunch - Multi-process improvements (thanks to @frank1734), instead of just using the main application we now respect caller process (also did it for HID devices while I was at it) - Layer stack masks & shared buffer screenshot for video core, added different masks (screenshot, recording, etc.) this was discovered as an issue due to how in qlaunch the transition was not right between applications. May not be perfect but also fixes screenshots while using qlaunch - Reworked overlay display management (input and visibility) - instead of random numbers as I've previously did, I decided to add an AppletZIndex enum for better readability. Also split capability of input by touch and gamepad. - etc. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4238 Reviewed-by: Samuel <lizzie@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
115 lines
3.3 KiB
C++
115 lines
3.3 KiB
C++
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <optional>
|
|
|
|
#include <QThread>
|
|
#include "common/common_types.h"
|
|
#include "common/logging.h"
|
|
#include "common/thread.h"
|
|
|
|
namespace Core {
|
|
class System;
|
|
} // namespace Core
|
|
|
|
namespace VideoCore {
|
|
enum class LoadCallbackStage;
|
|
} // namespace VideoCore
|
|
|
|
class EmuThread final : public QThread {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit EmuThread();
|
|
~EmuThread() override;
|
|
|
|
/**
|
|
* Start emulation (on new thread)
|
|
* @warning Only call when not running!
|
|
*/
|
|
void run() override;
|
|
|
|
/**
|
|
* Sets whether the emulation thread should run or not
|
|
* @param should_run Boolean value, set the emulation thread to running if true
|
|
*/
|
|
void SetRunning(bool should_run) {
|
|
// TODO: Prevent other threads from modifying the state until we finish.
|
|
{
|
|
// Notify the running thread to change state.
|
|
std::unique_lock run_lk{m_should_run_mutex};
|
|
m_should_run = should_run;
|
|
m_should_run_cv.notify_one();
|
|
}
|
|
|
|
// Wait until paused, if pausing.
|
|
if (!should_run) {
|
|
m_stopped.Wait();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check if the emulation thread is running or not
|
|
* @return True if the emulation thread is running, otherwise false
|
|
*/
|
|
bool IsRunning() const {
|
|
return m_should_run;
|
|
}
|
|
|
|
/**
|
|
* Requests for the emulation thread to immediately stop running
|
|
*/
|
|
void ForceStop() {
|
|
LOG_WARNING(Frontend, "Force stopping EmuThread");
|
|
m_stop_source.request_stop();
|
|
}
|
|
|
|
/**
|
|
* Requests that the disk shader cache be reloaded for a different title.
|
|
*/
|
|
void RequestDiskShaderCacheReload(u64 program_id) {
|
|
std::unique_lock run_lk{m_should_run_mutex};
|
|
m_pending_shader_cache_title = program_id;
|
|
m_should_run_cv.notify_one();
|
|
}
|
|
|
|
private:
|
|
void EmulationPaused(std::unique_lock<std::mutex>& lk);
|
|
void EmulationResumed(std::unique_lock<std::mutex>& lk);
|
|
void ReloadDiskShaderCache(u64 program_id);
|
|
|
|
private:
|
|
std::stop_source m_stop_source;
|
|
std::mutex m_should_run_mutex;
|
|
std::condition_variable_any m_should_run_cv;
|
|
Common::Event m_stopped;
|
|
bool m_should_run{true};
|
|
std::optional<u64> m_pending_shader_cache_title;
|
|
|
|
signals:
|
|
/**
|
|
* Emitted when the CPU has halted execution
|
|
*
|
|
* @warning When connecting to this signal from other threads, make sure to specify either
|
|
* Qt::QueuedConnection (invoke slot within the destination object's message thread) or even
|
|
* Qt::BlockingQueuedConnection (additionally block source thread until slot returns)
|
|
*/
|
|
void DebugModeEntered();
|
|
|
|
/**
|
|
* Emitted right before the CPU continues execution
|
|
*
|
|
* @warning When connecting to this signal from other threads, make sure to specify either
|
|
* Qt::QueuedConnection (invoke slot within the destination object's message thread) or even
|
|
* Qt::BlockingQueuedConnection (additionally block source thread until slot returns)
|
|
*/
|
|
void DebugModeLeft();
|
|
|
|
void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total);
|
|
|
|
void ShaderCacheReloadStarted();
|
|
void ShaderCacheReloadFinished();
|
|
};
|