Compare commits
43 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f261f22c9 | ||
|
|
ec4e2d1fab | ||
|
|
b5c0c1e163 | ||
|
|
4562f7af9a | ||
|
|
f3f57f90fe | ||
|
|
b5d61f214d | ||
|
|
3cf88a4d6c | ||
|
|
d72d753b1a | ||
|
|
a3ffea6a64 | ||
|
|
b014fdacdb | ||
|
|
757aafa582 | ||
|
|
9a9e5844d3 | ||
|
|
64dcb40db1 | ||
|
|
ba4213d956 | ||
|
|
d45ac00d48 | ||
|
|
484641003c | ||
|
|
a7792e5ff8 | ||
|
|
1d0fe75e7c | ||
|
|
6d61430311 | ||
|
|
b210174087 | ||
|
|
e6349fcd3b | ||
|
|
f7e6bda5cd | ||
|
|
31f0fa1065 | ||
|
|
3bd29fb66b | ||
|
|
c161e3f433 | ||
|
|
8a501ff30b | ||
|
|
97704b8da9 | ||
|
|
1f57ae6949 | ||
|
|
f01540da6c | ||
|
|
54711df739 | ||
|
|
644ee0043e | ||
|
|
376a414f5b | ||
|
|
026eaddbee | ||
|
|
3453beb1e0 | ||
|
|
194cf0b497 | ||
|
|
bff1453282 | ||
|
|
7e353082ac | ||
|
|
7fffdf83b7 | ||
|
|
1ed49f92dd | ||
|
|
bd09c82521 | ||
|
|
a7fb80e612 | ||
|
|
104cb6aa0a | ||
|
|
2ce5bb9bd6 |
@@ -477,8 +477,8 @@ if (APPLE)
|
||||
find_library(COCOA_LIBRARY Cocoa)
|
||||
set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY})
|
||||
elseif (WIN32)
|
||||
# WSAPoll and SHGetKnownFolderPath (AppData/Roaming) didn't exist before WinNT 6.x (Vista)
|
||||
add_definitions(-D_WIN32_WINNT=0x0600 -DWINVER=0x0600)
|
||||
# Target Windows 10
|
||||
add_definitions(-D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00)
|
||||
set(PLATFORM_LIBRARIES winmm ws2_32 iphlpapi)
|
||||
if (MINGW)
|
||||
# PSAPI is the Process Status API
|
||||
|
||||
6
dist/yuzu.manifest
vendored
6
dist/yuzu.manifest
vendored
@@ -36,12 +36,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
||||
<application>
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
<trustInfo
|
||||
|
||||
@@ -20,7 +20,7 @@ Manager::Manager(Core::System& system_) : system{system_} {
|
||||
Result Manager::AcquireSessionId(size_t& session_id) {
|
||||
if (num_free_sessions == 0) {
|
||||
LOG_ERROR(Service_Audio, "All 4 AudioIn sessions are in use, cannot create any more");
|
||||
return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED;
|
||||
return Service::Audio::ResultOutOfSessions;
|
||||
}
|
||||
session_id = session_ids[next_session_id];
|
||||
next_session_id = (next_session_id + 1) % MaxInSessions;
|
||||
|
||||
@@ -19,7 +19,7 @@ void AudioManager::Shutdown() {
|
||||
|
||||
Result AudioManager::SetOutManager(BufferEventFunc buffer_func) {
|
||||
if (!running) {
|
||||
return Service::Audio::ERR_OPERATION_FAILED;
|
||||
return Service::Audio::ResultOperationFailed;
|
||||
}
|
||||
|
||||
std::scoped_lock l{lock};
|
||||
@@ -35,7 +35,7 @@ Result AudioManager::SetOutManager(BufferEventFunc buffer_func) {
|
||||
|
||||
Result AudioManager::SetInManager(BufferEventFunc buffer_func) {
|
||||
if (!running) {
|
||||
return Service::Audio::ERR_OPERATION_FAILED;
|
||||
return Service::Audio::ResultOperationFailed;
|
||||
}
|
||||
|
||||
std::scoped_lock l{lock};
|
||||
|
||||
@@ -19,7 +19,7 @@ Manager::Manager(Core::System& system_) : system{system_} {
|
||||
Result Manager::AcquireSessionId(size_t& session_id) {
|
||||
if (num_free_sessions == 0) {
|
||||
LOG_ERROR(Service_Audio, "All 12 Audio Out sessions are in use, cannot create any more");
|
||||
return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED;
|
||||
return Service::Audio::ResultOutOfSessions;
|
||||
}
|
||||
session_id = session_ids[next_session_id];
|
||||
next_session_id = (next_session_id + 1) % MaxOutSessions;
|
||||
|
||||
@@ -28,7 +28,7 @@ SystemManager& Manager::GetSystemManager() {
|
||||
Result Manager::GetWorkBufferSize(const AudioRendererParameterInternal& params,
|
||||
u64& out_count) const {
|
||||
if (!CheckValidRevision(params.revision)) {
|
||||
return Service::Audio::ERR_INVALID_REVISION;
|
||||
return Service::Audio::ResultInvalidRevision;
|
||||
}
|
||||
|
||||
out_count = System::GetWorkBufferSize(params);
|
||||
|
||||
@@ -46,7 +46,7 @@ Result In::AppendBuffer(const AudioInBuffer& buffer, u64 tag) {
|
||||
if (system.AppendBuffer(buffer, tag)) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
return Service::Audio::ERR_BUFFER_COUNT_EXCEEDED;
|
||||
return Service::Audio::ResultBufferCountReached;
|
||||
}
|
||||
|
||||
void In::ReleaseAndRegisterBuffers() {
|
||||
|
||||
@@ -45,11 +45,11 @@ Result System::IsConfigValid(const std::string_view device_name,
|
||||
const AudioInParameter& in_params) const {
|
||||
if ((device_name.size() > 0) &&
|
||||
(device_name != GetDefaultDeviceName() && device_name != GetDefaultUacDeviceName())) {
|
||||
return Service::Audio::ERR_INVALID_DEVICE_NAME;
|
||||
return Service::Audio::ResultNotFound;
|
||||
}
|
||||
|
||||
if (in_params.sample_rate != TargetSampleRate && in_params.sample_rate > 0) {
|
||||
return Service::Audio::ERR_INVALID_SAMPLE_RATE;
|
||||
return Service::Audio::ResultInvalidSampleRate;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
@@ -80,7 +80,7 @@ Result System::Initialize(std::string device_name, const AudioInParameter& in_pa
|
||||
|
||||
Result System::Start() {
|
||||
if (state != State::Stopped) {
|
||||
return Service::Audio::ERR_OPERATION_FAILED;
|
||||
return Service::Audio::ResultOperationFailed;
|
||||
}
|
||||
|
||||
session->Initialize(name, sample_format, channel_count, session_id, handle,
|
||||
|
||||
@@ -46,7 +46,7 @@ Result Out::AppendBuffer(const AudioOutBuffer& buffer, const u64 tag) {
|
||||
if (system.AppendBuffer(buffer, tag)) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
return Service::Audio::ERR_BUFFER_COUNT_EXCEEDED;
|
||||
return Service::Audio::ResultBufferCountReached;
|
||||
}
|
||||
|
||||
void Out::ReleaseAndRegisterBuffers() {
|
||||
|
||||
@@ -33,11 +33,11 @@ std::string_view System::GetDefaultOutputDeviceName() const {
|
||||
Result System::IsConfigValid(std::string_view device_name,
|
||||
const AudioOutParameter& in_params) const {
|
||||
if ((device_name.size() > 0) && (device_name != GetDefaultOutputDeviceName())) {
|
||||
return Service::Audio::ERR_INVALID_DEVICE_NAME;
|
||||
return Service::Audio::ResultNotFound;
|
||||
}
|
||||
|
||||
if (in_params.sample_rate != TargetSampleRate && in_params.sample_rate > 0) {
|
||||
return Service::Audio::ERR_INVALID_SAMPLE_RATE;
|
||||
return Service::Audio::ResultInvalidSampleRate;
|
||||
}
|
||||
|
||||
if (in_params.channel_count == 0 || in_params.channel_count == 2 ||
|
||||
@@ -45,7 +45,7 @@ Result System::IsConfigValid(std::string_view device_name,
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
return Service::Audio::ERR_INVALID_CHANNEL_COUNT;
|
||||
return Service::Audio::ResultInvalidChannelCount;
|
||||
}
|
||||
|
||||
Result System::Initialize(std::string device_name, const AudioOutParameter& in_params, u32 handle_,
|
||||
@@ -80,7 +80,7 @@ size_t System::GetSessionId() const {
|
||||
|
||||
Result System::Start() {
|
||||
if (state != State::Stopped) {
|
||||
return Service::Audio::ERR_OPERATION_FAILED;
|
||||
return Service::Audio::ResultOperationFailed;
|
||||
}
|
||||
|
||||
session->Initialize(name, sample_format, channel_count, session_id, handle,
|
||||
|
||||
@@ -22,7 +22,7 @@ Result Renderer::Initialize(const AudioRendererParameterInternal& params,
|
||||
if (!manager.AddSystem(system)) {
|
||||
LOG_ERROR(Service_Audio,
|
||||
"Both Audio Render sessions are in use, cannot create any more");
|
||||
return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED;
|
||||
return Service::Audio::ResultOutOfSessions;
|
||||
}
|
||||
system_registered = true;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ Result InfoUpdater::UpdateVoiceChannelResources(VoiceContext& voice_context) {
|
||||
LOG_ERROR(Service_Audio,
|
||||
"Consumed an incorrect voice resource size, header size={}, consumed={}",
|
||||
in_header->voice_resources_size, consumed_input_size);
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
input += consumed_input_size;
|
||||
@@ -123,7 +123,7 @@ Result InfoUpdater::UpdateVoices(VoiceContext& voice_context,
|
||||
if (consumed_input_size != in_header->voices_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect voices size, header size={}, consumed={}",
|
||||
in_header->voices_size, consumed_input_size);
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
out_header->voices_size = consumed_output_size;
|
||||
@@ -184,7 +184,7 @@ Result InfoUpdater::UpdateEffectsVersion1(EffectContext& effect_context, const b
|
||||
if (consumed_input_size != in_header->effects_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}",
|
||||
in_header->effects_size, consumed_input_size);
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
out_header->effects_size = consumed_output_size;
|
||||
@@ -239,7 +239,7 @@ Result InfoUpdater::UpdateEffectsVersion2(EffectContext& effect_context, const b
|
||||
if (consumed_input_size != in_header->effects_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}",
|
||||
in_header->effects_size, consumed_input_size);
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
out_header->effects_size = consumed_output_size;
|
||||
@@ -267,7 +267,7 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co
|
||||
}
|
||||
|
||||
if (mix_buffer_count == 0) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
std::span<const MixInfo::InParameter> in_params{
|
||||
@@ -281,13 +281,13 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co
|
||||
total_buffer_count += params.buffer_count;
|
||||
if (params.dest_mix_id > static_cast<s32>(mix_context.GetCount()) &&
|
||||
params.dest_mix_id != UnusedMixId && params.mix_id != FinalMixId) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total_buffer_count > mix_buffer_count) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
bool mix_dirty{false};
|
||||
@@ -317,7 +317,7 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co
|
||||
if (mix_dirty) {
|
||||
if (behaviour.IsSplitterSupported() && splitter_context.UsingSplitter()) {
|
||||
if (!mix_context.TSortInfo(splitter_context)) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
} else {
|
||||
mix_context.SortInfo();
|
||||
@@ -327,7 +327,7 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co
|
||||
if (consumed_input_size != in_header->mix_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect mixes size, header size={}, consumed={}",
|
||||
in_header->mix_size, consumed_input_size);
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
input += mix_count * sizeof(MixInfo::InParameter);
|
||||
@@ -384,7 +384,7 @@ Result InfoUpdater::UpdateSinks(SinkContext& sink_context, std::span<MemoryPoolI
|
||||
if (consumed_input_size != in_header->sinks_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect sinks size, header size={}, consumed={}",
|
||||
in_header->sinks_size, consumed_input_size);
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
input += consumed_input_size;
|
||||
@@ -411,7 +411,7 @@ Result InfoUpdater::UpdateMemoryPools(std::span<MemoryPoolInfo> memory_pools,
|
||||
state != MemoryPoolInfo::ResultState::MapFailed &&
|
||||
state != MemoryPoolInfo::ResultState::InUse) {
|
||||
LOG_WARNING(Service_Audio, "Invalid ResultState from updating memory pools");
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ Result InfoUpdater::UpdateMemoryPools(std::span<MemoryPoolInfo> memory_pools,
|
||||
LOG_ERROR(Service_Audio,
|
||||
"Consumed an incorrect memory pool size, header size={}, consumed={}",
|
||||
in_header->memory_pool_size, consumed_input_size);
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
input += consumed_input_size;
|
||||
@@ -453,7 +453,7 @@ Result InfoUpdater::UpdatePerformanceBuffer(std::span<u8> performance_output,
|
||||
LOG_ERROR(Service_Audio,
|
||||
"Consumed an incorrect performance size, header size={}, consumed={}",
|
||||
in_header->performance_buffer_size, consumed_input_size);
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
input += consumed_input_size;
|
||||
@@ -467,18 +467,18 @@ Result InfoUpdater::UpdateBehaviorInfo(BehaviorInfo& behaviour_) {
|
||||
const auto in_params{reinterpret_cast<const BehaviorInfo::InParameter*>(input)};
|
||||
|
||||
if (!CheckValidRevision(in_params->revision)) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
if (in_params->revision != behaviour_.GetUserRevision()) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
behaviour_.ClearError();
|
||||
behaviour_.UpdateFlags(in_params->flags);
|
||||
|
||||
if (in_header->behaviour_size != sizeof(BehaviorInfo::InParameter)) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
input += sizeof(BehaviorInfo::InParameter);
|
||||
@@ -500,7 +500,7 @@ Result InfoUpdater::UpdateErrorInfo(const BehaviorInfo& behaviour_) {
|
||||
Result InfoUpdater::UpdateSplitterInfo(SplitterContext& splitter_context) {
|
||||
u32 consumed_size{0};
|
||||
if (!splitter_context.Update(input, consumed_size)) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
|
||||
input += consumed_size;
|
||||
@@ -529,9 +529,9 @@ Result InfoUpdater::UpdateRendererInfo(const u64 elapsed_frames) {
|
||||
|
||||
Result InfoUpdater::CheckConsumedSize() {
|
||||
if (CpuAddr(input) - CpuAddr(input_origin.data()) != expected_input_size) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
} else if (CpuAddr(output) - CpuAddr(output_origin.data()) != expected_output_size) {
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
}
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
@@ -308,7 +308,8 @@ static void ApplyReverbEffect(const ReverbInfo::ParameterVersion2& params, Rever
|
||||
}
|
||||
|
||||
Common::FixedPoint<50, 14> pre_delay_sample{
|
||||
state.pre_delay_line.Read() * Common::FixedPoint<50, 14>::from_base(params.late_gain)};
|
||||
state.pre_delay_line.TapOut(state.pre_delay_time) *
|
||||
Common::FixedPoint<50, 14>::from_base(params.late_gain)};
|
||||
|
||||
std::array<Common::FixedPoint<50, 14>, ReverbInfo::MaxDelayLines> mix_matrix{
|
||||
state.prev_feedback_output[2] + state.prev_feedback_output[1] + pre_delay_sample,
|
||||
|
||||
@@ -104,7 +104,8 @@ public:
|
||||
}
|
||||
|
||||
void Write(const Common::FixedPoint<50, 14> sample) {
|
||||
*(input++) = sample;
|
||||
*input = sample;
|
||||
input++;
|
||||
if (input >= buffer_end) {
|
||||
input = buffer.data();
|
||||
}
|
||||
|
||||
@@ -79,12 +79,10 @@ public:
|
||||
return;
|
||||
}
|
||||
sample_count = delay_time;
|
||||
input = &buffer[(output - buffer.data() + sample_count) % (sample_count_max + 1)];
|
||||
input = &buffer[0];
|
||||
}
|
||||
|
||||
Common::FixedPoint<50, 14> Tick(const Common::FixedPoint<50, 14> sample) {
|
||||
Write(sample);
|
||||
|
||||
auto out_sample{Read()};
|
||||
|
||||
output++;
|
||||
@@ -92,6 +90,7 @@ public:
|
||||
output = buffer.data();
|
||||
}
|
||||
|
||||
Write(sample);
|
||||
return out_sample;
|
||||
}
|
||||
|
||||
@@ -100,7 +99,8 @@ public:
|
||||
}
|
||||
|
||||
void Write(const Common::FixedPoint<50, 14> sample) {
|
||||
*(input++) = sample;
|
||||
*input = sample;
|
||||
input++;
|
||||
if (input >= buffer_end) {
|
||||
input = buffer.data();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ bool PoolMapper::TryAttachBuffer(BehaviorInfo::ErrorInfo& error_info, AddressInf
|
||||
address_info.Setup(address, size);
|
||||
|
||||
if (!FillDspAddr(address_info)) {
|
||||
error_info.error_code = Service::Audio::ERR_POOL_MAPPING_FAILED;
|
||||
error_info.error_code = Service::Audio::ResultInvalidAddressInfo;
|
||||
error_info.address = address;
|
||||
return force_map;
|
||||
}
|
||||
|
||||
@@ -101,15 +101,15 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||
u32 process_handle_, u64 applet_resource_user_id_, s32 session_id_) {
|
||||
if (!CheckValidRevision(params.revision)) {
|
||||
return Service::Audio::ERR_INVALID_REVISION;
|
||||
return Service::Audio::ResultInvalidRevision;
|
||||
}
|
||||
|
||||
if (GetWorkBufferSize(params) > transfer_memory_size) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
if (process_handle_ == 0) {
|
||||
return Service::Audio::ERR_INVALID_PROCESS_HANDLE;
|
||||
return Service::Audio::ResultInvalidHandle;
|
||||
}
|
||||
|
||||
behavior.SetUserLibRevision(params.revision);
|
||||
@@ -143,19 +143,19 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
samples_workbuffer =
|
||||
allocator.Allocate<s32>((voice_channels + mix_buffer_count) * sample_count, 0x10);
|
||||
if (samples_workbuffer.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
auto upsampler_workbuffer{allocator.Allocate<s32>(
|
||||
(voice_channels + mix_buffer_count) * TargetSampleCount * upsampler_count, 0x10)};
|
||||
if (upsampler_workbuffer.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
depop_buffer =
|
||||
allocator.Allocate<s32>(Common::AlignUp(static_cast<u32>(mix_buffer_count), 0x40), 0x40);
|
||||
if (depop_buffer.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
// invalidate samples_workbuffer DSP cache
|
||||
@@ -166,12 +166,12 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
}
|
||||
|
||||
if (voice_infos.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
auto sorted_voice_infos{allocator.Allocate<VoiceInfo*>(params.voices, 0x10)};
|
||||
if (sorted_voice_infos.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
std::memset(sorted_voice_infos.data(), 0, sorted_voice_infos.size_bytes());
|
||||
@@ -183,12 +183,12 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
}
|
||||
|
||||
if (voice_channel_resources.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
auto voice_cpu_states{allocator.Allocate<VoiceState>(params.voices, 0x10)};
|
||||
if (voice_cpu_states.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
for (auto& voice_state : voice_cpu_states) {
|
||||
@@ -198,7 +198,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
auto mix_infos{allocator.Allocate<MixInfo>(params.sub_mixes + 1, 0x10)};
|
||||
|
||||
if (mix_infos.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
u32 effect_process_order_count{0};
|
||||
@@ -208,7 +208,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
effect_process_order_count = params.effects * (params.sub_mixes + 1);
|
||||
effect_process_order_buffer = allocator.Allocate<s32>(effect_process_order_count, 0x10);
|
||||
if (effect_process_order_buffer.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
|
||||
auto sorted_mix_infos{allocator.Allocate<MixInfo*>(params.sub_mixes + 1, 0x10)};
|
||||
if (sorted_mix_infos.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
std::memset(sorted_mix_infos.data(), 0, sorted_mix_infos.size_bytes());
|
||||
@@ -235,7 +235,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
auto edge_matrix_workbuffer{allocator.Allocate<u8>(edge_matrix_size, 1)};
|
||||
|
||||
if (node_states_workbuffer.empty() || edge_matrix_workbuffer.size() == 0) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
mix_context.Initialize(sorted_mix_infos, mix_infos, params.sub_mixes + 1,
|
||||
@@ -250,7 +250,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
|
||||
upsampler_manager = allocator.Allocate<UpsamplerManager>(1, 0x10).data();
|
||||
if (upsampler_manager == nullptr) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
memory_pool_workbuffer = allocator.Allocate<MemoryPoolInfo>(memory_pool_count, 0x10);
|
||||
@@ -259,18 +259,18 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
}
|
||||
|
||||
if (memory_pool_workbuffer.empty() && memory_pool_count > 0) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
if (!splitter_context.Initialize(behavior, params, allocator)) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
std::span<EffectResultState> effect_result_states_cpu{};
|
||||
if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) {
|
||||
effect_result_states_cpu = allocator.Allocate<EffectResultState>(params.effects, 0x10);
|
||||
if (effect_result_states_cpu.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
std::memset(effect_result_states_cpu.data(), 0, effect_result_states_cpu.size_bytes());
|
||||
}
|
||||
@@ -289,7 +289,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
upsampler_workbuffer);
|
||||
|
||||
if (upsampler_infos.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
auto effect_infos{allocator.Allocate<EffectInfoBase>(params.effects, 0x40)};
|
||||
@@ -298,14 +298,14 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
}
|
||||
|
||||
if (effect_infos.empty() && params.effects > 0) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
std::span<EffectResultState> effect_result_states_dsp{};
|
||||
if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) {
|
||||
effect_result_states_dsp = allocator.Allocate<EffectResultState>(params.effects, 0x40);
|
||||
if (effect_result_states_dsp.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
std::memset(effect_result_states_dsp.data(), 0, effect_result_states_dsp.size_bytes());
|
||||
}
|
||||
@@ -319,14 +319,14 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
}
|
||||
|
||||
if (sinks.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
sink_context.Initialize(sinks, params.sinks);
|
||||
|
||||
auto voice_dsp_states{allocator.Allocate<VoiceState>(params.voices, 0x40)};
|
||||
if (voice_dsp_states.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
for (auto& voice_state : voice_dsp_states) {
|
||||
@@ -344,7 +344,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
0xC};
|
||||
performance_workbuffer = allocator.Allocate<u8>(perf_workbuffer_size, 0x40);
|
||||
if (performance_workbuffer.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
std::memset(performance_workbuffer.data(), 0, performance_workbuffer.size_bytes());
|
||||
performance_manager.Initialize(performance_workbuffer, performance_workbuffer.size_bytes(),
|
||||
@@ -360,7 +360,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||
command_workbuffer_size = allocator.GetRemainingSize();
|
||||
command_workbuffer = allocator.Allocate<u8>(command_workbuffer_size, 0x40);
|
||||
if (command_workbuffer.empty()) {
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
}
|
||||
|
||||
command_buffer_size = 0;
|
||||
|
||||
@@ -181,7 +181,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info,
|
||||
if (wave_buffer_internal.start_offset * byte_size > wave_buffer_internal.size ||
|
||||
wave_buffer_internal.end_offset * byte_size > wave_buffer_internal.size) {
|
||||
LOG_ERROR(Service_Audio, "Invalid PCM16 start/end wavebuffer sizes!");
|
||||
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo;
|
||||
error_info[0].address = wave_buffer_internal.address;
|
||||
return;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info,
|
||||
if (wave_buffer_internal.start_offset * byte_size > wave_buffer_internal.size ||
|
||||
wave_buffer_internal.end_offset * byte_size > wave_buffer_internal.size) {
|
||||
LOG_ERROR(Service_Audio, "Invalid PCMFloat start/end wavebuffer sizes!");
|
||||
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo;
|
||||
error_info[0].address = wave_buffer_internal.address;
|
||||
return;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info,
|
||||
if (start > static_cast<s64>(wave_buffer_internal.size) ||
|
||||
end > static_cast<s64>(wave_buffer_internal.size)) {
|
||||
LOG_ERROR(Service_Audio, "Invalid ADPCM start/end wavebuffer sizes!");
|
||||
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo;
|
||||
error_info[0].address = wave_buffer_internal.address;
|
||||
return;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info,
|
||||
|
||||
if (wave_buffer_internal.start_offset < 0 || wave_buffer_internal.end_offset < 0) {
|
||||
LOG_ERROR(Service_Audio, "Invalid input start/end wavebuffer sizes!");
|
||||
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo;
|
||||
error_info[0].address = wave_buffer_internal.address;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ add_library(common STATIC
|
||||
multi_level_page_table.h
|
||||
nvidia_flags.cpp
|
||||
nvidia_flags.h
|
||||
overflow.h
|
||||
page_table.cpp
|
||||
page_table.h
|
||||
param_package.cpp
|
||||
@@ -113,6 +114,8 @@ add_library(common STATIC
|
||||
socket_types.h
|
||||
spin_lock.cpp
|
||||
spin_lock.h
|
||||
steady_clock.cpp
|
||||
steady_clock.h
|
||||
stream.cpp
|
||||
stream.h
|
||||
string_util.cpp
|
||||
@@ -142,6 +145,14 @@ add_library(common STATIC
|
||||
zstd_compression.h
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
target_sources(common PRIVATE
|
||||
windows/timer_resolution.cpp
|
||||
windows/timer_resolution.h
|
||||
)
|
||||
target_link_libraries(common PRIVATE ntdll)
|
||||
endif()
|
||||
|
||||
if(ARCHITECTURE_x86_64)
|
||||
target_sources(common
|
||||
PRIVATE
|
||||
|
||||
@@ -3,19 +3,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
#include <version>
|
||||
|
||||
#ifdef __cpp_lib_bit_cast
|
||||
#include <bit>
|
||||
#endif
|
||||
|
||||
namespace Common {
|
||||
|
||||
template <typename To, typename From>
|
||||
[[nodiscard]] std::enable_if_t<sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> &&
|
||||
std::is_trivially_copyable_v<To>,
|
||||
To>
|
||||
BitCast(const From& src) noexcept {
|
||||
To dst;
|
||||
std::memcpy(&dst, &src, sizeof(To));
|
||||
return dst;
|
||||
constexpr inline To BitCast(const From& from) {
|
||||
#ifdef __cpp_lib_bit_cast
|
||||
return std::bit_cast<To>(from);
|
||||
#else
|
||||
return __builtin_bit_cast(To, from);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Common
|
||||
|
||||
@@ -46,7 +46,7 @@ enum class PollingMode {
|
||||
// Constant polling of buttons, analogs and motion data
|
||||
Active,
|
||||
// Only update on button change, digital analogs
|
||||
Pasive,
|
||||
Passive,
|
||||
// Enable near field communication polling
|
||||
NFC,
|
||||
// Enable infrared camera polling
|
||||
|
||||
22
src/common/overflow.h
Normal file
22
src/common/overflow.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include "bit_cast.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_integral_v<T> && std::is_signed_v<T>)
|
||||
inline T WrappingAdd(T lhs, T rhs) {
|
||||
using U = std::make_unsigned_t<T>;
|
||||
|
||||
U lhs_u = BitCast<U>(lhs);
|
||||
U rhs_u = BitCast<U>(rhs);
|
||||
|
||||
return BitCast<T>(lhs_u + rhs_u);
|
||||
}
|
||||
|
||||
} // namespace Common
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
/**
|
||||
* Sets a default value, label, and setting value.
|
||||
*
|
||||
* @param default_val Intial value of the setting, and default value of the setting
|
||||
* @param default_val Initial value of the setting, and default value of the setting
|
||||
* @param name Label for the setting
|
||||
*/
|
||||
explicit Setting(const Type& default_val, const std::string& name)
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
/**
|
||||
* Sets a default value, minimum value, maximum value, and label.
|
||||
*
|
||||
* @param default_val Intial value of the setting, and default value of the setting
|
||||
* @param default_val Initial value of the setting, and default value of the setting
|
||||
* @param min_val Sets the minimum allowed value of the setting
|
||||
* @param max_val Sets the maximum allowed value of the setting
|
||||
* @param name Label for the setting
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
/**
|
||||
* Sets a default value, label, and setting value.
|
||||
*
|
||||
* @param default_val Intial value of the setting, and default value of the setting
|
||||
* @param default_val Initial value of the setting, and default value of the setting
|
||||
* @param name Label for the setting
|
||||
*/
|
||||
explicit SwitchableSetting(const Type& default_val, const std::string& name)
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
/**
|
||||
* Sets a default value, minimum value, maximum value, and label.
|
||||
*
|
||||
* @param default_val Intial value of the setting, and default value of the setting
|
||||
* @param default_val Initial value of the setting, and default value of the setting
|
||||
* @param min_val Sets the minimum allowed value of the setting
|
||||
* @param max_val Sets the maximum allowed value of the setting
|
||||
* @param name Label for the setting
|
||||
@@ -503,7 +503,7 @@ struct Values {
|
||||
Setting<bool> tas_loop{false, "tas_loop"};
|
||||
|
||||
Setting<bool> mouse_panning{false, "mouse_panning"};
|
||||
Setting<u8, true> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"};
|
||||
Setting<u8, true> mouse_panning_sensitivity{50, 1, 100, "mouse_panning_sensitivity"};
|
||||
Setting<bool> mouse_enabled{false, "mouse_enabled"};
|
||||
|
||||
Setting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"};
|
||||
|
||||
56
src/common/steady_clock.cpp
Normal file
56
src/common/steady_clock.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#include "common/steady_clock.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
#ifdef _WIN32
|
||||
static s64 WindowsQueryPerformanceFrequency() {
|
||||
LARGE_INTEGER frequency;
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
return frequency.QuadPart;
|
||||
}
|
||||
|
||||
static s64 WindowsQueryPerformanceCounter() {
|
||||
LARGE_INTEGER counter;
|
||||
QueryPerformanceCounter(&counter);
|
||||
return counter.QuadPart;
|
||||
}
|
||||
#endif
|
||||
|
||||
SteadyClock::time_point SteadyClock::Now() noexcept {
|
||||
#if defined(_WIN32)
|
||||
static const auto freq = WindowsQueryPerformanceFrequency();
|
||||
const auto counter = WindowsQueryPerformanceCounter();
|
||||
|
||||
// 10 MHz is a very common QPC frequency on modern PCs.
|
||||
// Optimizing for this specific frequency can double the performance of
|
||||
// this function by avoiding the expensive frequency conversion path.
|
||||
static constexpr s64 TenMHz = 10'000'000;
|
||||
|
||||
if (freq == TenMHz) [[likely]] {
|
||||
static_assert(period::den % TenMHz == 0);
|
||||
static constexpr s64 Multiplier = period::den / TenMHz;
|
||||
return time_point{duration{counter * Multiplier}};
|
||||
}
|
||||
|
||||
const auto whole = (counter / freq) * period::den;
|
||||
const auto part = (counter % freq) * period::den / freq;
|
||||
return time_point{duration{whole + part}};
|
||||
#elif defined(__APPLE__)
|
||||
return time_point{duration{clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)}};
|
||||
#else
|
||||
timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return time_point{std::chrono::seconds{ts.tv_sec} + std::chrono::nanoseconds{ts.tv_nsec}};
|
||||
#endif
|
||||
}
|
||||
|
||||
}; // namespace Common
|
||||
23
src/common/steady_clock.h
Normal file
23
src/common/steady_clock.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
struct SteadyClock {
|
||||
using rep = s64;
|
||||
using period = std::nano;
|
||||
using duration = std::chrono::nanoseconds;
|
||||
using time_point = std::chrono::time_point<SteadyClock>;
|
||||
|
||||
static constexpr bool is_steady = true;
|
||||
|
||||
[[nodiscard]] static time_point Now() noexcept;
|
||||
};
|
||||
|
||||
} // namespace Common
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/steady_clock.h"
|
||||
#include "common/uint128.h"
|
||||
#include "common/wall_clock.h"
|
||||
|
||||
@@ -11,45 +12,32 @@
|
||||
|
||||
namespace Common {
|
||||
|
||||
using base_timer = std::chrono::steady_clock;
|
||||
using base_time_point = std::chrono::time_point<base_timer>;
|
||||
|
||||
class StandardWallClock final : public WallClock {
|
||||
public:
|
||||
explicit StandardWallClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequency_)
|
||||
: WallClock(emulated_cpu_frequency_, emulated_clock_frequency_, false) {
|
||||
start_time = base_timer::now();
|
||||
}
|
||||
: WallClock{emulated_cpu_frequency_, emulated_clock_frequency_, false},
|
||||
start_time{SteadyClock::Now()} {}
|
||||
|
||||
std::chrono::nanoseconds GetTimeNS() override {
|
||||
base_time_point current = base_timer::now();
|
||||
auto elapsed = current - start_time;
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed);
|
||||
return SteadyClock::Now() - start_time;
|
||||
}
|
||||
|
||||
std::chrono::microseconds GetTimeUS() override {
|
||||
base_time_point current = base_timer::now();
|
||||
auto elapsed = current - start_time;
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(elapsed);
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(GetTimeNS());
|
||||
}
|
||||
|
||||
std::chrono::milliseconds GetTimeMS() override {
|
||||
base_time_point current = base_timer::now();
|
||||
auto elapsed = current - start_time;
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(elapsed);
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(GetTimeNS());
|
||||
}
|
||||
|
||||
u64 GetClockCycles() override {
|
||||
std::chrono::nanoseconds time_now = GetTimeNS();
|
||||
const u128 temporary =
|
||||
Common::Multiply64Into128(time_now.count(), emulated_clock_frequency);
|
||||
return Common::Divide128On32(temporary, 1000000000).first;
|
||||
const u128 temp = Common::Multiply64Into128(GetTimeNS().count(), emulated_clock_frequency);
|
||||
return Common::Divide128On32(temp, NS_RATIO).first;
|
||||
}
|
||||
|
||||
u64 GetCPUCycles() override {
|
||||
std::chrono::nanoseconds time_now = GetTimeNS();
|
||||
const u128 temporary = Common::Multiply64Into128(time_now.count(), emulated_cpu_frequency);
|
||||
return Common::Divide128On32(temporary, 1000000000).first;
|
||||
const u128 temp = Common::Multiply64Into128(GetTimeNS().count(), emulated_cpu_frequency);
|
||||
return Common::Divide128On32(temp, NS_RATIO).first;
|
||||
}
|
||||
|
||||
void Pause([[maybe_unused]] bool is_paused) override {
|
||||
@@ -57,7 +45,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
base_time_point start_time;
|
||||
SteadyClock::time_point start_time;
|
||||
};
|
||||
|
||||
#ifdef ARCHITECTURE_x86_64
|
||||
@@ -93,4 +81,9 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
|
||||
|
||||
#endif
|
||||
|
||||
std::unique_ptr<WallClock> CreateStandardWallClock(u64 emulated_cpu_frequency,
|
||||
u64 emulated_clock_frequency) {
|
||||
return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency);
|
||||
}
|
||||
|
||||
} // namespace Common
|
||||
|
||||
@@ -55,4 +55,7 @@ private:
|
||||
[[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
|
||||
u64 emulated_clock_frequency);
|
||||
|
||||
[[nodiscard]] std::unique_ptr<WallClock> CreateStandardWallClock(u64 emulated_cpu_frequency,
|
||||
u64 emulated_clock_frequency);
|
||||
|
||||
} // namespace Common
|
||||
|
||||
109
src/common/windows/timer_resolution.cpp
Normal file
109
src/common/windows/timer_resolution.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "common/windows/timer_resolution.h"
|
||||
|
||||
extern "C" {
|
||||
// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FTime%2FNtQueryTimerResolution.html
|
||||
NTSYSAPI LONG NTAPI NtQueryTimerResolution(PULONG MinimumResolution, PULONG MaximumResolution,
|
||||
PULONG CurrentResolution);
|
||||
|
||||
// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FTime%2FNtSetTimerResolution.html
|
||||
NTSYSAPI LONG NTAPI NtSetTimerResolution(ULONG DesiredResolution, BOOLEAN SetResolution,
|
||||
PULONG CurrentResolution);
|
||||
|
||||
// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FThread%2FNtDelayExecution.html
|
||||
NTSYSAPI LONG NTAPI NtDelayExecution(BOOLEAN Alertable, PLARGE_INTEGER DelayInterval);
|
||||
}
|
||||
|
||||
// Defines for compatibility with older Windows 10 SDKs.
|
||||
|
||||
#ifndef PROCESS_POWER_THROTTLING_EXECUTION_SPEED
|
||||
#define PROCESS_POWER_THROTTLING_EXECUTION_SPEED 0x1
|
||||
#endif
|
||||
#ifndef PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION
|
||||
#define PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION 0x4
|
||||
#endif
|
||||
|
||||
namespace Common::Windows {
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
constexpr nanoseconds ToNS(ULONG hundred_ns) {
|
||||
return nanoseconds{hundred_ns * 100};
|
||||
}
|
||||
|
||||
constexpr ULONG ToHundredNS(nanoseconds ns) {
|
||||
return static_cast<ULONG>(ns.count()) / 100;
|
||||
}
|
||||
|
||||
struct TimerResolution {
|
||||
std::chrono::nanoseconds minimum;
|
||||
std::chrono::nanoseconds maximum;
|
||||
std::chrono::nanoseconds current;
|
||||
};
|
||||
|
||||
TimerResolution GetTimerResolution() {
|
||||
ULONG MinimumTimerResolution;
|
||||
ULONG MaximumTimerResolution;
|
||||
ULONG CurrentTimerResolution;
|
||||
NtQueryTimerResolution(&MinimumTimerResolution, &MaximumTimerResolution,
|
||||
&CurrentTimerResolution);
|
||||
return {
|
||||
.minimum{ToNS(MinimumTimerResolution)},
|
||||
.maximum{ToNS(MaximumTimerResolution)},
|
||||
.current{ToNS(CurrentTimerResolution)},
|
||||
};
|
||||
}
|
||||
|
||||
void SetHighQoS() {
|
||||
// https://learn.microsoft.com/en-us/windows/win32/procthread/quality-of-service
|
||||
PROCESS_POWER_THROTTLING_STATE PowerThrottling{
|
||||
.Version{PROCESS_POWER_THROTTLING_CURRENT_VERSION},
|
||||
.ControlMask{PROCESS_POWER_THROTTLING_EXECUTION_SPEED |
|
||||
PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION},
|
||||
.StateMask{},
|
||||
};
|
||||
SetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, &PowerThrottling,
|
||||
sizeof(PROCESS_POWER_THROTTLING_STATE));
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
nanoseconds GetMinimumTimerResolution() {
|
||||
return GetTimerResolution().minimum;
|
||||
}
|
||||
|
||||
nanoseconds GetMaximumTimerResolution() {
|
||||
return GetTimerResolution().maximum;
|
||||
}
|
||||
|
||||
nanoseconds GetCurrentTimerResolution() {
|
||||
return GetTimerResolution().current;
|
||||
}
|
||||
|
||||
nanoseconds SetCurrentTimerResolution(nanoseconds timer_resolution) {
|
||||
// Set the timer resolution, and return the current timer resolution.
|
||||
const auto DesiredTimerResolution = ToHundredNS(timer_resolution);
|
||||
ULONG CurrentTimerResolution;
|
||||
NtSetTimerResolution(DesiredTimerResolution, TRUE, &CurrentTimerResolution);
|
||||
return ToNS(CurrentTimerResolution);
|
||||
}
|
||||
|
||||
nanoseconds SetCurrentTimerResolutionToMaximum() {
|
||||
SetHighQoS();
|
||||
return SetCurrentTimerResolution(GetMaximumTimerResolution());
|
||||
}
|
||||
|
||||
void SleepForOneTick() {
|
||||
LARGE_INTEGER DelayInterval{
|
||||
.QuadPart{-1},
|
||||
};
|
||||
NtDelayExecution(FALSE, &DelayInterval);
|
||||
}
|
||||
|
||||
} // namespace Common::Windows
|
||||
38
src/common/windows/timer_resolution.h
Normal file
38
src/common/windows/timer_resolution.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace Common::Windows {
|
||||
|
||||
/// Returns the minimum (least precise) supported timer resolution in nanoseconds.
|
||||
std::chrono::nanoseconds GetMinimumTimerResolution();
|
||||
|
||||
/// Returns the maximum (most precise) supported timer resolution in nanoseconds.
|
||||
std::chrono::nanoseconds GetMaximumTimerResolution();
|
||||
|
||||
/// Returns the current timer resolution in nanoseconds.
|
||||
std::chrono::nanoseconds GetCurrentTimerResolution();
|
||||
|
||||
/**
|
||||
* Sets the current timer resolution.
|
||||
*
|
||||
* @param timer_resolution Timer resolution in nanoseconds.
|
||||
*
|
||||
* @returns The current timer resolution.
|
||||
*/
|
||||
std::chrono::nanoseconds SetCurrentTimerResolution(std::chrono::nanoseconds timer_resolution);
|
||||
|
||||
/**
|
||||
* Sets the current timer resolution to the maximum supported timer resolution.
|
||||
*
|
||||
* @returns The current timer resolution.
|
||||
*/
|
||||
std::chrono::nanoseconds SetCurrentTimerResolutionToMaximum();
|
||||
|
||||
/// Sleep for one tick of the current timer resolution.
|
||||
void SleepForOneTick();
|
||||
|
||||
} // namespace Common::Windows
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <thread>
|
||||
|
||||
#include "common/atomic_ops.h"
|
||||
#include "common/steady_clock.h"
|
||||
#include "common/uint128.h"
|
||||
#include "common/x64/native_clock.h"
|
||||
|
||||
@@ -39,6 +40,12 @@ static u64 FencedRDTSC() {
|
||||
}
|
||||
#endif
|
||||
|
||||
template <u64 Nearest>
|
||||
static u64 RoundToNearest(u64 value) {
|
||||
const auto mod = value % Nearest;
|
||||
return mod >= (Nearest / 2) ? (value - mod + Nearest) : (value - mod);
|
||||
}
|
||||
|
||||
u64 EstimateRDTSCFrequency() {
|
||||
// Discard the first result measuring the rdtsc.
|
||||
FencedRDTSC();
|
||||
@@ -46,18 +53,18 @@ u64 EstimateRDTSCFrequency() {
|
||||
FencedRDTSC();
|
||||
|
||||
// Get the current time.
|
||||
const auto start_time = std::chrono::steady_clock::now();
|
||||
const auto start_time = Common::SteadyClock::Now();
|
||||
const u64 tsc_start = FencedRDTSC();
|
||||
// Wait for 200 milliseconds.
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{200});
|
||||
const auto end_time = std::chrono::steady_clock::now();
|
||||
// Wait for 250 milliseconds.
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{250});
|
||||
const auto end_time = Common::SteadyClock::Now();
|
||||
const u64 tsc_end = FencedRDTSC();
|
||||
// Calculate differences.
|
||||
const u64 timer_diff = static_cast<u64>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count());
|
||||
const u64 tsc_diff = tsc_end - tsc_start;
|
||||
const u64 tsc_freq = MultiplyAndDivide64(tsc_diff, 1000000000ULL, timer_diff);
|
||||
return tsc_freq;
|
||||
return RoundToNearest<1000>(tsc_freq);
|
||||
}
|
||||
|
||||
namespace X64 {
|
||||
|
||||
@@ -454,7 +454,6 @@ add_library(core STATIC
|
||||
hle/service/filesystem/fsp_srv.h
|
||||
hle/service/fgm/fgm.cpp
|
||||
hle/service/fgm/fgm.h
|
||||
hle/service/friend/errors.h
|
||||
hle/service/friend/friend.cpp
|
||||
hle/service/friend/friend.h
|
||||
hle/service/friend/friend_interface.cpp
|
||||
|
||||
@@ -4,13 +4,24 @@
|
||||
#include "core/constants.h"
|
||||
|
||||
namespace Core::Constants {
|
||||
const std::array<u8, 107> ACCOUNT_BACKUP_JPEG{{
|
||||
0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02,
|
||||
0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05,
|
||||
0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e,
|
||||
0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13,
|
||||
0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01,
|
||||
0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08,
|
||||
0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
|
||||
const std::array<u8, 287> ACCOUNT_BACKUP_JPEG{{
|
||||
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48,
|
||||
0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x06, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06,
|
||||
0x05, 0x05, 0x06, 0x09, 0x06, 0x05, 0x06, 0x09, 0x0b, 0x08, 0x06, 0x06, 0x08, 0x0b, 0x0c, 0x0a,
|
||||
0x0a, 0x0b, 0x0a, 0x0a, 0x0c, 0x10, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x10, 0x0c, 0x0e, 0x0f,
|
||||
0x10, 0x0f, 0x0e, 0x0c, 0x13, 0x13, 0x14, 0x14, 0x13, 0x13, 0x1c, 0x1b, 0x1b, 0x1b, 0x1c, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x07, 0x07,
|
||||
0x07, 0x0d, 0x0c, 0x0d, 0x18, 0x10, 0x10, 0x18, 0x1a, 0x15, 0x11, 0x15, 0x1a, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0xc0,
|
||||
0x00, 0x11, 0x08, 0x00, 0x20, 0x00, 0x20, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11,
|
||||
0x01, 0xff, 0xc4, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x10, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00,
|
||||
0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00,
|
||||
0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xd9,
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
namespace Core::Constants {
|
||||
|
||||
// ACC Service - Blank JPEG used as user icon in absentia of real one.
|
||||
extern const std::array<u8, 107> ACCOUNT_BACKUP_JPEG;
|
||||
extern const std::array<u8, 287> ACCOUNT_BACKUP_JPEG;
|
||||
|
||||
} // namespace Core::Constants
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "common/windows/timer_resolution.h"
|
||||
#endif
|
||||
|
||||
#include "common/microprofile.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/core_timing_util.h"
|
||||
@@ -38,7 +42,8 @@ struct CoreTiming::Event {
|
||||
};
|
||||
|
||||
CoreTiming::CoreTiming()
|
||||
: clock{Common::CreateBestMatchingClock(Hardware::BASE_CLOCK_RATE, Hardware::CNTFREQ)} {}
|
||||
: cpu_clock{Common::CreateBestMatchingClock(Hardware::BASE_CLOCK_RATE, Hardware::CNTFREQ)},
|
||||
event_clock{Common::CreateStandardWallClock(Hardware::BASE_CLOCK_RATE, Hardware::CNTFREQ)} {}
|
||||
|
||||
CoreTiming::~CoreTiming() {
|
||||
Reset();
|
||||
@@ -185,15 +190,15 @@ void CoreTiming::ResetTicks() {
|
||||
}
|
||||
|
||||
u64 CoreTiming::GetCPUTicks() const {
|
||||
if (is_multicore) {
|
||||
return clock->GetCPUCycles();
|
||||
if (is_multicore) [[likely]] {
|
||||
return cpu_clock->GetCPUCycles();
|
||||
}
|
||||
return ticks;
|
||||
}
|
||||
|
||||
u64 CoreTiming::GetClockTicks() const {
|
||||
if (is_multicore) {
|
||||
return clock->GetClockCycles();
|
||||
if (is_multicore) [[likely]] {
|
||||
return cpu_clock->GetClockCycles();
|
||||
}
|
||||
return CpuCyclesToClockCycles(ticks);
|
||||
}
|
||||
@@ -252,21 +257,20 @@ void CoreTiming::ThreadLoop() {
|
||||
const auto next_time = Advance();
|
||||
if (next_time) {
|
||||
// There are more events left in the queue, wait until the next event.
|
||||
const auto wait_time = *next_time - GetGlobalTimeNs().count();
|
||||
auto wait_time = *next_time - GetGlobalTimeNs().count();
|
||||
if (wait_time > 0) {
|
||||
#ifdef _WIN32
|
||||
// Assume a timer resolution of 1ms.
|
||||
static constexpr s64 TimerResolutionNS = 1000000;
|
||||
const auto timer_resolution_ns =
|
||||
Common::Windows::GetCurrentTimerResolution().count();
|
||||
|
||||
// Sleep in discrete intervals of the timer resolution, and spin the rest.
|
||||
const auto sleep_time = wait_time - (wait_time % TimerResolutionNS);
|
||||
if (sleep_time > 0) {
|
||||
event.WaitFor(std::chrono::nanoseconds(sleep_time));
|
||||
}
|
||||
while (!paused && !event.IsSet() && wait_time > 0) {
|
||||
wait_time = *next_time - GetGlobalTimeNs().count();
|
||||
|
||||
while (!paused && !event.IsSet() && GetGlobalTimeNs().count() < *next_time) {
|
||||
// Yield to reduce thread starvation.
|
||||
std::this_thread::yield();
|
||||
if (wait_time >= timer_resolution_ns) {
|
||||
Common::Windows::SleepForOneTick();
|
||||
} else {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.IsSet()) {
|
||||
@@ -285,9 +289,9 @@ void CoreTiming::ThreadLoop() {
|
||||
}
|
||||
|
||||
paused_set = true;
|
||||
clock->Pause(true);
|
||||
event_clock->Pause(true);
|
||||
pause_event.Wait();
|
||||
clock->Pause(false);
|
||||
event_clock->Pause(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,16 +307,23 @@ void CoreTiming::Reset() {
|
||||
has_started = false;
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds CoreTiming::GetCPUTimeNs() const {
|
||||
if (is_multicore) [[likely]] {
|
||||
return cpu_clock->GetTimeNS();
|
||||
}
|
||||
return CyclesToNs(ticks);
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds CoreTiming::GetGlobalTimeNs() const {
|
||||
if (is_multicore) {
|
||||
return clock->GetTimeNS();
|
||||
if (is_multicore) [[likely]] {
|
||||
return event_clock->GetTimeNS();
|
||||
}
|
||||
return CyclesToNs(ticks);
|
||||
}
|
||||
|
||||
std::chrono::microseconds CoreTiming::GetGlobalTimeUs() const {
|
||||
if (is_multicore) {
|
||||
return clock->GetTimeUS();
|
||||
if (is_multicore) [[likely]] {
|
||||
return event_clock->GetTimeUS();
|
||||
}
|
||||
return CyclesToUs(ticks);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,9 @@ public:
|
||||
/// Returns current time in emulated in Clock cycles
|
||||
u64 GetClockTicks() const;
|
||||
|
||||
/// Returns current time in nanoseconds.
|
||||
std::chrono::nanoseconds GetCPUTimeNs() const;
|
||||
|
||||
/// Returns current time in microseconds.
|
||||
std::chrono::microseconds GetGlobalTimeUs() const;
|
||||
|
||||
@@ -139,7 +142,8 @@ private:
|
||||
|
||||
void Reset();
|
||||
|
||||
std::unique_ptr<Common::WallClock> clock;
|
||||
std::unique_ptr<Common::WallClock> cpu_clock;
|
||||
std::unique_ptr<Common::WallClock> event_clock;
|
||||
|
||||
s64 global_timer = 0;
|
||||
|
||||
|
||||
@@ -13,11 +13,9 @@ namespace Core {
|
||||
|
||||
namespace Hardware {
|
||||
|
||||
// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz
|
||||
// The exact value used is of course unverified.
|
||||
constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch cpu frequency is 1020MHz un/docked
|
||||
constexpr u64 CNTFREQ = 19200000; // Switch's hardware clock speed
|
||||
constexpr u32 NUM_CPU_CORES = 4; // Number of CPU Cores
|
||||
constexpr u64 BASE_CLOCK_RATE = 1'020'000'000; // Default CPU Frequency = 1020 MHz
|
||||
constexpr u64 CNTFREQ = 19'200'000; // CNTPCT_EL0 Frequency = 19.2 MHz
|
||||
constexpr u32 NUM_CPU_CORES = 4; // Number of CPU Cores
|
||||
|
||||
// Virtual to Physical core map.
|
||||
constexpr std::array<s32, Common::BitSize<u64>()> VirtualToPhysicalCoreMap{
|
||||
|
||||
@@ -44,11 +44,11 @@ const KAddressSpaceInfo& GetAddressSpaceInfo(size_t width, KAddressSpaceInfo::Ty
|
||||
|
||||
} // namespace
|
||||
|
||||
uintptr_t KAddressSpaceInfo::GetAddressSpaceStart(size_t width, KAddressSpaceInfo::Type type) {
|
||||
std::size_t KAddressSpaceInfo::GetAddressSpaceStart(size_t width, KAddressSpaceInfo::Type type) {
|
||||
return GetAddressSpaceInfo(width, type).address;
|
||||
}
|
||||
|
||||
size_t KAddressSpaceInfo::GetAddressSpaceSize(size_t width, KAddressSpaceInfo::Type type) {
|
||||
std::size_t KAddressSpaceInfo::GetAddressSpaceSize(size_t width, KAddressSpaceInfo::Type type) {
|
||||
return GetAddressSpaceInfo(width, type).size;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ struct KAddressSpaceInfo final {
|
||||
Count,
|
||||
};
|
||||
|
||||
static u64 GetAddressSpaceStart(std::size_t width, Type type);
|
||||
static std::size_t GetAddressSpaceStart(std::size_t width, Type type);
|
||||
static std::size_t GetAddressSpaceSize(std::size_t width, Type type);
|
||||
|
||||
const std::size_t bit_width{};
|
||||
|
||||
@@ -21,9 +21,9 @@ public:
|
||||
~KDeviceAddressSpace();
|
||||
|
||||
Result Initialize(u64 address, u64 size);
|
||||
void Finalize();
|
||||
void Finalize() override;
|
||||
|
||||
bool IsInitialized() const {
|
||||
bool IsInitialized() const override {
|
||||
return m_is_initialized;
|
||||
}
|
||||
static void PostDestroy(uintptr_t arg) {}
|
||||
|
||||
@@ -310,10 +310,10 @@ public:
|
||||
/// Clears the signaled state of the process if and only if it's signaled.
|
||||
///
|
||||
/// @pre The process must not be already terminated. If this is called on a
|
||||
/// terminated process, then ERR_INVALID_STATE will be returned.
|
||||
/// terminated process, then ResultInvalidState will be returned.
|
||||
///
|
||||
/// @pre The process must be in a signaled state. If this is called on a
|
||||
/// process instance that is not signaled, ERR_INVALID_STATE will be
|
||||
/// process instance that is not signaled, ResultInvalidState will be
|
||||
/// returned.
|
||||
Result Reset();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/overflow.h"
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/k_resource_limit.h"
|
||||
@@ -104,7 +105,7 @@ bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) {
|
||||
ASSERT(current_hints[index] <= current_values[index]);
|
||||
|
||||
// If we would overflow, don't allow to succeed.
|
||||
if (current_values[index] + value <= current_values[index]) {
|
||||
if (Common::WrappingAdd(current_values[index], value) <= current_values[index]) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ static void ResetThreadContext32(Core::ARM_Interface::ThreadContext32& context,
|
||||
context.cpu_registers[0] = arg;
|
||||
context.cpu_registers[15] = entry_point;
|
||||
context.cpu_registers[13] = stack_top;
|
||||
context.fpscr = 0;
|
||||
}
|
||||
|
||||
static void ResetThreadContext64(Core::ARM_Interface::ThreadContext64& context, VAddr stack_top,
|
||||
@@ -58,8 +59,8 @@ static void ResetThreadContext64(Core::ARM_Interface::ThreadContext64& context,
|
||||
context.cpu_registers[18] = Kernel::KSystemControl::GenerateRandomU64() | 1;
|
||||
context.pc = entry_point;
|
||||
context.sp = stack_top;
|
||||
// TODO(merry): Perform a hardware test to determine the below value.
|
||||
context.fpcr = 0;
|
||||
context.fpsr = 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -815,6 +816,27 @@ void KThread::Continue() {
|
||||
KScheduler::OnThreadStateChanged(kernel, this, old_state);
|
||||
}
|
||||
|
||||
void KThread::CloneFpuStatus() {
|
||||
// We shouldn't reach here when starting kernel threads.
|
||||
ASSERT(this->GetOwnerProcess() != nullptr);
|
||||
ASSERT(this->GetOwnerProcess() == GetCurrentProcessPointer(kernel));
|
||||
|
||||
if (this->GetOwnerProcess()->Is64BitProcess()) {
|
||||
// Clone FPSR and FPCR.
|
||||
ThreadContext64 cur_ctx{};
|
||||
kernel.System().CurrentArmInterface().SaveContext(cur_ctx);
|
||||
|
||||
this->GetContext64().fpcr = cur_ctx.fpcr;
|
||||
this->GetContext64().fpsr = cur_ctx.fpsr;
|
||||
} else {
|
||||
// Clone FPSCR.
|
||||
ThreadContext32 cur_ctx{};
|
||||
kernel.System().CurrentArmInterface().SaveContext(cur_ctx);
|
||||
|
||||
this->GetContext32().fpscr = cur_ctx.fpscr;
|
||||
}
|
||||
}
|
||||
|
||||
Result KThread::SetActivity(Svc::ThreadActivity activity) {
|
||||
// Lock ourselves.
|
||||
KScopedLightLock lk(activity_pause_lock);
|
||||
|
||||
@@ -254,6 +254,8 @@ public:
|
||||
thread_context_32.tpidr = static_cast<u32>(value);
|
||||
}
|
||||
|
||||
void CloneFpuStatus();
|
||||
|
||||
[[nodiscard]] ThreadContext32& GetContext32() {
|
||||
return thread_context_32;
|
||||
}
|
||||
|
||||
@@ -48,19 +48,15 @@ Result ResetSignal(Core::System& system, Handle handle) {
|
||||
return ResultInvalidHandle;
|
||||
}
|
||||
|
||||
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
|
||||
Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, s32 num_handles,
|
||||
s64 nano_seconds) {
|
||||
LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, num_handles={}, nano_seconds={}",
|
||||
handles_address, num_handles, nano_seconds);
|
||||
|
||||
static Result WaitSynchronization(Core::System& system, int32_t* out_index, const Handle* handles,
|
||||
int32_t num_handles, int64_t timeout_ns) {
|
||||
// Ensure number of handles is valid.
|
||||
R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange);
|
||||
R_UNLESS(0 <= num_handles && num_handles <= Svc::ArgumentHandleCountMax, ResultOutOfRange);
|
||||
|
||||
// Get the synchronization context.
|
||||
auto& kernel = system.Kernel();
|
||||
auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
|
||||
std::vector<KSynchronizationObject*> objs(num_handles);
|
||||
const auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
|
||||
Handle* handles = system.Memory().GetPointer<Handle>(handles_address);
|
||||
|
||||
// Copy user handles.
|
||||
if (num_handles > 0) {
|
||||
@@ -68,21 +64,38 @@ Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_addre
|
||||
R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles,
|
||||
num_handles),
|
||||
ResultInvalidHandle);
|
||||
for (const auto& obj : objs) {
|
||||
kernel.RegisterInUseObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure handles are closed when we're done.
|
||||
SCOPE_EXIT({
|
||||
for (s32 i = 0; i < num_handles; ++i) {
|
||||
kernel.UnregisterInUseObject(objs[i]);
|
||||
for (auto i = 0; i < num_handles; ++i) {
|
||||
objs[i]->Close();
|
||||
}
|
||||
});
|
||||
|
||||
return KSynchronizationObject::Wait(kernel, index, objs.data(), static_cast<s32>(objs.size()),
|
||||
nano_seconds);
|
||||
// Wait on the objects.
|
||||
Result res = KSynchronizationObject::Wait(kernel, out_index, objs.data(),
|
||||
static_cast<s32>(objs.size()), timeout_ns);
|
||||
|
||||
R_SUCCEED_IF(res == ResultSessionClosed);
|
||||
R_RETURN(res);
|
||||
}
|
||||
|
||||
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
|
||||
Result WaitSynchronization(Core::System& system, int32_t* out_index, VAddr user_handles,
|
||||
int32_t num_handles, int64_t timeout_ns) {
|
||||
LOG_TRACE(Kernel_SVC, "called user_handles={:#x}, num_handles={}, timeout_ns={}", user_handles,
|
||||
num_handles, timeout_ns);
|
||||
|
||||
// Ensure number of handles is valid.
|
||||
R_UNLESS(0 <= num_handles && num_handles <= Svc::ArgumentHandleCountMax, ResultOutOfRange);
|
||||
|
||||
std::vector<Handle> handles(num_handles);
|
||||
if (num_handles > 0) {
|
||||
system.Memory().ReadBlock(user_handles, handles.data(), num_handles * sizeof(Handle));
|
||||
}
|
||||
|
||||
R_RETURN(WaitSynchronization(system, out_index, handles.data(), num_handles, timeout_ns));
|
||||
}
|
||||
|
||||
/// Resumes a thread waiting on WaitSynchronization
|
||||
|
||||
@@ -82,6 +82,9 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
|
||||
// Commit the thread reservation.
|
||||
thread_reservation.Commit();
|
||||
|
||||
// Clone the current fpu status to the new thread.
|
||||
thread->CloneFpuStatus();
|
||||
|
||||
// Register the new thread.
|
||||
KThread::Register(kernel, thread);
|
||||
|
||||
|
||||
@@ -30,12 +30,6 @@
|
||||
|
||||
namespace Service::Account {
|
||||
|
||||
constexpr Result ERR_INVALID_USER_ID{ErrorModule::Account, 20};
|
||||
constexpr Result ERR_INVALID_APPLICATION_ID{ErrorModule::Account, 22};
|
||||
constexpr Result ERR_INVALID_BUFFER{ErrorModule::Account, 30};
|
||||
constexpr Result ERR_INVALID_BUFFER_SIZE{ErrorModule::Account, 31};
|
||||
constexpr Result ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100};
|
||||
|
||||
// Thumbnails are hard coded to be at least this size
|
||||
constexpr std::size_t THUMBNAIL_SIZE = 0x24000;
|
||||
|
||||
@@ -384,7 +378,7 @@ protected:
|
||||
if (user_data.size() < sizeof(UserData)) {
|
||||
LOG_ERROR(Service_ACC, "UserData buffer too small!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_INVALID_BUFFER);
|
||||
rb.Push(Account::ResultInvalidArrayLength);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -394,7 +388,7 @@ protected:
|
||||
if (!profile_manager.SetProfileBaseAndData(user_id, base, data)) {
|
||||
LOG_ERROR(Service_ACC, "Failed to update user data and base!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_FAILED_SAVE_DATA);
|
||||
rb.Push(Account::ResultAccountUpdateFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -417,7 +411,7 @@ protected:
|
||||
if (user_data.size() < sizeof(UserData)) {
|
||||
LOG_ERROR(Service_ACC, "UserData buffer too small!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_INVALID_BUFFER);
|
||||
rb.Push(Account::ResultInvalidArrayLength);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -432,7 +426,7 @@ protected:
|
||||
!profile_manager.SetProfileBaseAndData(user_id, base, data)) {
|
||||
LOG_ERROR(Service_ACC, "Failed to update profile data, base, and image!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_FAILED_SAVE_DATA);
|
||||
rb.Push(Account::ResultAccountUpdateFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -764,7 +758,7 @@ void Module::Interface::InitializeApplicationInfoRestricted(HLERequestContext& c
|
||||
Result Module::Interface::InitializeApplicationInfoBase() {
|
||||
if (application_info) {
|
||||
LOG_ERROR(Service_ACC, "Application already initialized");
|
||||
return ERR_ACCOUNTINFO_ALREADY_INITIALIZED;
|
||||
return Account::ResultApplicationInfoAlreadyInitialized;
|
||||
}
|
||||
|
||||
// TODO(ogniK): This should be changed to reflect the target process for when we have multiple
|
||||
@@ -775,7 +769,7 @@ Result Module::Interface::InitializeApplicationInfoBase() {
|
||||
|
||||
if (launch_property.Failed()) {
|
||||
LOG_ERROR(Service_ACC, "Failed to get launch property");
|
||||
return ERR_ACCOUNTINFO_BAD_APPLICATION;
|
||||
return Account::ResultInvalidApplication;
|
||||
}
|
||||
|
||||
switch (launch_property->base_game_storage_id) {
|
||||
@@ -791,7 +785,7 @@ Result Module::Interface::InitializeApplicationInfoBase() {
|
||||
default:
|
||||
LOG_ERROR(Service_ACC, "Invalid game storage ID! storage_id={}",
|
||||
launch_property->base_game_storage_id);
|
||||
return ERR_ACCOUNTINFO_BAD_APPLICATION;
|
||||
return Account::ResultInvalidApplication;
|
||||
}
|
||||
|
||||
LOG_WARNING(Service_ACC, "ApplicationInfo init required");
|
||||
@@ -899,20 +893,20 @@ void Module::Interface::StoreSaveDataThumbnail(HLERequestContext& ctx, const Com
|
||||
|
||||
if (tid == 0) {
|
||||
LOG_ERROR(Service_ACC, "TitleID is not valid!");
|
||||
rb.Push(ERR_INVALID_APPLICATION_ID);
|
||||
rb.Push(Account::ResultInvalidApplication);
|
||||
return;
|
||||
}
|
||||
|
||||
if (uuid.IsInvalid()) {
|
||||
LOG_ERROR(Service_ACC, "User ID is not valid!");
|
||||
rb.Push(ERR_INVALID_USER_ID);
|
||||
rb.Push(Account::ResultInvalidUserId);
|
||||
return;
|
||||
}
|
||||
const auto thumbnail_size = ctx.GetReadBufferSize();
|
||||
if (thumbnail_size != THUMBNAIL_SIZE) {
|
||||
LOG_ERROR(Service_ACC, "Buffer size is empty! size={:X} expecting {:X}", thumbnail_size,
|
||||
THUMBNAIL_SIZE);
|
||||
rb.Push(ERR_INVALID_BUFFER_SIZE);
|
||||
rb.Push(Account::ResultInvalidArrayLength);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,13 @@
|
||||
|
||||
namespace Service::Account {
|
||||
|
||||
constexpr Result ERR_ACCOUNTINFO_BAD_APPLICATION{ErrorModule::Account, 22};
|
||||
constexpr Result ERR_ACCOUNTINFO_ALREADY_INITIALIZED{ErrorModule::Account, 41};
|
||||
constexpr Result ResultCancelledByUser{ErrorModule::Account, 1};
|
||||
constexpr Result ResultNoNotifications{ErrorModule::Account, 15};
|
||||
constexpr Result ResultInvalidUserId{ErrorModule::Account, 20};
|
||||
constexpr Result ResultInvalidApplication{ErrorModule::Account, 22};
|
||||
constexpr Result ResultNullptr{ErrorModule::Account, 30};
|
||||
constexpr Result ResultInvalidArrayLength{ErrorModule::Account, 32};
|
||||
constexpr Result ResultApplicationInfoAlreadyInitialized{ErrorModule::Account, 41};
|
||||
constexpr Result ResultAccountUpdateFailed{ErrorModule::Account, 100};
|
||||
|
||||
} // namespace Service::Account
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
|
||||
namespace Service::AM {
|
||||
|
||||
constexpr Result ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 2};
|
||||
constexpr Result ERR_NO_MESSAGES{ErrorModule::AM, 3};
|
||||
constexpr Result ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 503};
|
||||
constexpr Result ResultNoDataInChannel{ErrorModule::AM, 2};
|
||||
constexpr Result ResultNoMessages{ErrorModule::AM, 3};
|
||||
constexpr Result ResultInvalidOffset{ErrorModule::AM, 503};
|
||||
|
||||
enum class LaunchParameterKind : u32 {
|
||||
ApplicationSpecific = 1,
|
||||
@@ -758,7 +758,7 @@ void ICommonStateGetter::ReceiveMessage(HLERequestContext& ctx) {
|
||||
|
||||
if (message == AppletMessageQueue::AppletMessage::None) {
|
||||
LOG_ERROR(Service_AM, "Message queue is empty");
|
||||
rb.Push(ERR_NO_MESSAGES);
|
||||
rb.Push(AM::ResultNoMessages);
|
||||
rb.PushEnum<AppletMessageQueue::AppletMessage>(message);
|
||||
return;
|
||||
}
|
||||
@@ -1028,7 +1028,7 @@ private:
|
||||
LOG_DEBUG(Service_AM,
|
||||
"storage is a nullptr. There is no data in the current normal channel");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_NO_DATA_IN_CHANNEL);
|
||||
rb.Push(AM::ResultNoDataInChannel);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1059,7 +1059,7 @@ private:
|
||||
LOG_DEBUG(Service_AM,
|
||||
"storage is a nullptr. There is no data in the current interactive channel");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_NO_DATA_IN_CHANNEL);
|
||||
rb.Push(AM::ResultNoDataInChannel);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1138,7 +1138,7 @@ void IStorageAccessor::Write(HLERequestContext& ctx) {
|
||||
backing.GetSize(), size, offset);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
|
||||
rb.Push(AM::ResultInvalidOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1161,7 +1161,7 @@ void IStorageAccessor::Read(HLERequestContext& ctx) {
|
||||
backing.GetSize(), size, offset);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
|
||||
rb.Push(AM::ResultInvalidOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1502,7 +1502,7 @@ void IApplicationFunctions::PopLaunchParameter(HLERequestContext& ctx) {
|
||||
|
||||
LOG_ERROR(Service_AM, "Attempted to load launch parameter but none was found!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_NO_DATA_IN_CHANNEL);
|
||||
rb.Push(AM::ResultNoDataInChannel);
|
||||
}
|
||||
|
||||
void IApplicationFunctions::CreateApplicationAndRequestToStartForQuest(HLERequestContext& ctx) {
|
||||
@@ -1799,7 +1799,7 @@ void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel(HLERequestC
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_NO_DATA_IN_CHANNEL);
|
||||
rb.Push(AM::ResultNoDataInChannel);
|
||||
}
|
||||
|
||||
void IApplicationFunctions::GetNotificationStorageChannelEvent(HLERequestContext& ctx) {
|
||||
|
||||
@@ -19,10 +19,9 @@
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
|
||||
// This error code (0x183ACA) is thrown when the applet fails to initialize.
|
||||
[[maybe_unused]] constexpr Result ERR_CONTROLLER_APPLET_3101{ErrorModule::HID, 3101};
|
||||
// This error code (0x183CCA) is thrown when the u32 result in ControllerSupportResultInfo is 2.
|
||||
[[maybe_unused]] constexpr Result ERR_CONTROLLER_APPLET_3102{ErrorModule::HID, 3102};
|
||||
[[maybe_unused]] constexpr Result ResultControllerSupportCanceled{ErrorModule::HID, 3101};
|
||||
[[maybe_unused]] constexpr Result ResultControllerSupportNotSupportedNpadStyle{ErrorModule::HID,
|
||||
3102};
|
||||
|
||||
static Core::Frontend::ControllerParameters ConvertToFrontendParameters(
|
||||
ControllerSupportArgPrivate private_arg, ControllerSupportArgHeader header, bool enable_text,
|
||||
|
||||
@@ -7,13 +7,12 @@
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/frontend/applets/profile_select.h"
|
||||
#include "core/hle/service/acc/errors.h"
|
||||
#include "core/hle/service/am/am.h"
|
||||
#include "core/hle/service/am/applets/applet_profile_select.h"
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
|
||||
constexpr Result ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1};
|
||||
|
||||
ProfileSelect::ProfileSelect(Core::System& system_, LibraryAppletMode applet_mode_,
|
||||
const Core::Frontend::ProfileSelectApplet& frontend_)
|
||||
: Applet{system_, applet_mode_}, frontend{frontend_}, system{system_} {}
|
||||
@@ -63,8 +62,8 @@ void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
|
||||
output.result = 0;
|
||||
output.uuid_selected = *uuid;
|
||||
} else {
|
||||
status = ERR_USER_CANCELLED_SELECTION;
|
||||
output.result = ERR_USER_CANCELLED_SELECTION.raw;
|
||||
status = Account::ResultCancelledByUser;
|
||||
output.result = Account::ResultCancelledByUser.raw;
|
||||
output.uuid_selected = Common::InvalidUUID;
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ private:
|
||||
|
||||
if (impl->GetSystem().GetExecutionMode() == AudioCore::ExecutionMode::Manual) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_NOT_SUPPORTED);
|
||||
rb.Push(Audio::ResultNotSupported);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ void AudRenU::OpenAudioRenderer(HLERequestContext& ctx) {
|
||||
if (impl->GetSessionCount() + 1 > AudioCore::MaxRendererSessions) {
|
||||
LOG_ERROR(Service_Audio, "Too many AudioRenderer sessions open!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_MAXIMUM_SESSIONS_REACHED);
|
||||
rb.Push(Audio::ResultOutOfSessions);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ void AudRenU::OpenAudioRenderer(HLERequestContext& ctx) {
|
||||
if (session_id == -1) {
|
||||
LOG_ERROR(Service_Audio, "Tried to open a session that's already in use!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_MAXIMUM_SESSIONS_REACHED);
|
||||
rb.Push(Audio::ResultOutOfSessions);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
|
||||
namespace Service::Audio {
|
||||
|
||||
constexpr Result ERR_INVALID_DEVICE_NAME{ErrorModule::Audio, 1};
|
||||
constexpr Result ERR_OPERATION_FAILED{ErrorModule::Audio, 2};
|
||||
constexpr Result ERR_INVALID_SAMPLE_RATE{ErrorModule::Audio, 3};
|
||||
constexpr Result ERR_INSUFFICIENT_BUFFER_SIZE{ErrorModule::Audio, 4};
|
||||
constexpr Result ERR_MAXIMUM_SESSIONS_REACHED{ErrorModule::Audio, 5};
|
||||
constexpr Result ERR_BUFFER_COUNT_EXCEEDED{ErrorModule::Audio, 8};
|
||||
constexpr Result ERR_INVALID_CHANNEL_COUNT{ErrorModule::Audio, 10};
|
||||
constexpr Result ERR_INVALID_UPDATE_DATA{ErrorModule::Audio, 41};
|
||||
constexpr Result ERR_POOL_MAPPING_FAILED{ErrorModule::Audio, 42};
|
||||
constexpr Result ERR_NOT_SUPPORTED{ErrorModule::Audio, 513};
|
||||
constexpr Result ERR_INVALID_PROCESS_HANDLE{ErrorModule::Audio, 1536};
|
||||
constexpr Result ERR_INVALID_REVISION{ErrorModule::Audio, 1537};
|
||||
constexpr Result ResultNotFound{ErrorModule::Audio, 1};
|
||||
constexpr Result ResultOperationFailed{ErrorModule::Audio, 2};
|
||||
constexpr Result ResultInvalidSampleRate{ErrorModule::Audio, 3};
|
||||
constexpr Result ResultInsufficientBuffer{ErrorModule::Audio, 4};
|
||||
constexpr Result ResultOutOfSessions{ErrorModule::Audio, 5};
|
||||
constexpr Result ResultBufferCountReached{ErrorModule::Audio, 8};
|
||||
constexpr Result ResultInvalidChannelCount{ErrorModule::Audio, 10};
|
||||
constexpr Result ResultInvalidUpdateInfo{ErrorModule::Audio, 41};
|
||||
constexpr Result ResultInvalidAddressInfo{ErrorModule::Audio, 42};
|
||||
constexpr Result ResultNotSupported{ErrorModule::Audio, 513};
|
||||
constexpr Result ResultInvalidHandle{ErrorModule::Audio, 1536};
|
||||
constexpr Result ResultInvalidRevision{ErrorModule::Audio, 1537};
|
||||
|
||||
} // namespace Service::Audio
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/result.h"
|
||||
|
||||
namespace Service::Friend {
|
||||
|
||||
constexpr Result ERR_NO_NOTIFICATIONS{ErrorModule::Account, 15};
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "common/uuid.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/service/friend/errors.h"
|
||||
#include "core/hle/service/acc/errors.h"
|
||||
#include "core/hle/service/friend/friend.h"
|
||||
#include "core/hle/service/friend/friend_interface.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
@@ -259,7 +259,7 @@ private:
|
||||
if (notifications.empty()) {
|
||||
LOG_ERROR(Service_Friend, "No notifications in queue!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_NO_NOTIFICATIONS);
|
||||
rb.Push(Account::ResultNoNotifications);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ void ARP_R::GetApplicationLaunchProperty(HLERequestContext& ctx) {
|
||||
if (!title_id.has_value()) {
|
||||
LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_NOT_REGISTERED);
|
||||
rb.Push(Glue::ResultProcessIdNotRegistered);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ void ARP_R::GetApplicationControlProperty(HLERequestContext& ctx) {
|
||||
if (!title_id.has_value()) {
|
||||
LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_NOT_REGISTERED);
|
||||
rb.Push(Glue::ResultProcessIdNotRegistered);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ private:
|
||||
if (process_id == 0) {
|
||||
LOG_ERROR(Service_ARP, "Must have non-zero process ID!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_INVALID_PROCESS_ID);
|
||||
rb.Push(Glue::ResultInvalidProcessId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ private:
|
||||
LOG_ERROR(Service_ARP,
|
||||
"Attempted to issue registrar, but registrar is already issued!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_INVALID_ACCESS);
|
||||
rb.Push(Glue::ResultAlreadyBound);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ private:
|
||||
Service_ARP,
|
||||
"Attempted to set application launch property, but registrar is already issued!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_INVALID_ACCESS);
|
||||
rb.Push(Glue::ResultAlreadyBound);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ private:
|
||||
Service_ARP,
|
||||
"Attempted to set application control property, but registrar is already issued!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_INVALID_ACCESS);
|
||||
rb.Push(Glue::ResultAlreadyBound);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ void ARP_W::AcquireRegistrar(HLERequestContext& ctx) {
|
||||
system, [this](u64 process_id, ApplicationLaunchProperty launch, std::vector<u8> control) {
|
||||
const auto res = GetTitleIDForProcessID(system, process_id);
|
||||
if (!res.has_value()) {
|
||||
return ERR_NOT_REGISTERED;
|
||||
return Glue::ResultProcessIdNotRegistered;
|
||||
}
|
||||
|
||||
return manager.Register(*res, launch, std::move(control));
|
||||
@@ -283,7 +283,7 @@ void ARP_W::UnregisterApplicationInstance(HLERequestContext& ctx) {
|
||||
if (process_id == 0) {
|
||||
LOG_ERROR(Service_ARP, "Must have non-zero process ID!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_INVALID_PROCESS_ID);
|
||||
rb.Push(Glue::ResultInvalidProcessId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ void ARP_W::UnregisterApplicationInstance(HLERequestContext& ctx) {
|
||||
if (!title_id.has_value()) {
|
||||
LOG_ERROR(Service_ARP, "No title ID for process ID!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_NOT_REGISTERED);
|
||||
rb.Push(Glue::ResultProcessIdNotRegistered);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
|
||||
namespace Service::Glue {
|
||||
|
||||
constexpr Result ERR_INVALID_RESOURCE{ErrorModule::ARP, 30};
|
||||
constexpr Result ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 31};
|
||||
constexpr Result ERR_INVALID_ACCESS{ErrorModule::ARP, 42};
|
||||
constexpr Result ERR_NOT_REGISTERED{ErrorModule::ARP, 102};
|
||||
constexpr Result ResultInvalidProcessId{ErrorModule::ARP, 31};
|
||||
constexpr Result ResultAlreadyBound{ErrorModule::ARP, 42};
|
||||
constexpr Result ResultProcessIdNotRegistered{ErrorModule::ARP, 102};
|
||||
|
||||
} // namespace Service::Glue
|
||||
|
||||
@@ -17,12 +17,12 @@ ARPManager::~ARPManager() = default;
|
||||
|
||||
ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const {
|
||||
if (title_id == 0) {
|
||||
return ERR_INVALID_PROCESS_ID;
|
||||
return Glue::ResultInvalidProcessId;
|
||||
}
|
||||
|
||||
const auto iter = entries.find(title_id);
|
||||
if (iter == entries.end()) {
|
||||
return ERR_NOT_REGISTERED;
|
||||
return Glue::ResultProcessIdNotRegistered;
|
||||
}
|
||||
|
||||
return iter->second.launch;
|
||||
@@ -30,12 +30,12 @@ ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id)
|
||||
|
||||
ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
|
||||
if (title_id == 0) {
|
||||
return ERR_INVALID_PROCESS_ID;
|
||||
return Glue::ResultInvalidProcessId;
|
||||
}
|
||||
|
||||
const auto iter = entries.find(title_id);
|
||||
if (iter == entries.end()) {
|
||||
return ERR_NOT_REGISTERED;
|
||||
return Glue::ResultProcessIdNotRegistered;
|
||||
}
|
||||
|
||||
return iter->second.control;
|
||||
@@ -44,12 +44,12 @@ ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
|
||||
Result ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
|
||||
std::vector<u8> control) {
|
||||
if (title_id == 0) {
|
||||
return ERR_INVALID_PROCESS_ID;
|
||||
return Glue::ResultInvalidProcessId;
|
||||
}
|
||||
|
||||
const auto iter = entries.find(title_id);
|
||||
if (iter != entries.end()) {
|
||||
return ERR_INVALID_ACCESS;
|
||||
return Glue::ResultAlreadyBound;
|
||||
}
|
||||
|
||||
entries.insert_or_assign(title_id, MapEntry{launch, std::move(control)});
|
||||
@@ -58,12 +58,12 @@ Result ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
|
||||
|
||||
Result ARPManager::Unregister(u64 title_id) {
|
||||
if (title_id == 0) {
|
||||
return ERR_INVALID_PROCESS_ID;
|
||||
return Glue::ResultInvalidProcessId;
|
||||
}
|
||||
|
||||
const auto iter = entries.find(title_id);
|
||||
if (iter == entries.end()) {
|
||||
return ERR_NOT_REGISTERED;
|
||||
return Glue::ResultProcessIdNotRegistered;
|
||||
}
|
||||
|
||||
entries.erase(iter);
|
||||
|
||||
@@ -30,23 +30,23 @@ public:
|
||||
~ARPManager();
|
||||
|
||||
// Returns the ApplicationLaunchProperty corresponding to the provided title ID if it was
|
||||
// previously registered, otherwise ERR_NOT_REGISTERED if it was never registered or
|
||||
// ERR_INVALID_PROCESS_ID if the title ID is 0.
|
||||
// previously registered, otherwise ResultProcessIdNotRegistered if it was never registered or
|
||||
// ResultInvalidProcessId if the title ID is 0.
|
||||
ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const;
|
||||
|
||||
// Returns a vector of the raw bytes of NACP data (necessarily 0x4000 in size) corresponding to
|
||||
// the provided title ID if it was previously registered, otherwise ERR_NOT_REGISTERED if it was
|
||||
// never registered or ERR_INVALID_PROCESS_ID if the title ID is 0.
|
||||
// the provided title ID if it was previously registered, otherwise ResultProcessIdNotRegistered
|
||||
// if it was never registered or ResultInvalidProcessId if the title ID is 0.
|
||||
ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const;
|
||||
|
||||
// Adds a new entry to the internal database with the provided parameters, returning
|
||||
// ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister
|
||||
// step, and ERR_INVALID_PROCESS_ID if the title ID is 0.
|
||||
// ResultProcessIdNotRegistered if attempting to re-register a title ID without an intermediate
|
||||
// Unregister step, and ResultInvalidProcessId if the title ID is 0.
|
||||
Result Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
|
||||
|
||||
// Removes the registration for the provided title ID from the database, returning
|
||||
// ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the
|
||||
// title ID is 0.
|
||||
// ResultProcessIdNotRegistered if it doesn't exist in the database and ResultInvalidProcessId
|
||||
// if the title ID is 0.
|
||||
Result Unregister(u64 title_id);
|
||||
|
||||
// Removes all entries from the database, always succeeds. Should only be used when resetting
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
namespace IPC {
|
||||
|
||||
constexpr Result ERR_REMOTE_PROCESS_DEAD{ErrorModule::HIPC, 301};
|
||||
constexpr Result ResultSessionClosed{ErrorModule::HIPC, 301};
|
||||
|
||||
class RequestHelperBase {
|
||||
protected:
|
||||
|
||||
@@ -7,5 +7,6 @@
|
||||
|
||||
namespace Service::NS {
|
||||
|
||||
constexpr Result ERR_APPLICATION_LANGUAGE_NOT_FOUND{ErrorModule::NS, 300};
|
||||
}
|
||||
constexpr Result ResultApplicationLanguageNotFound{ErrorModule::NS, 300};
|
||||
|
||||
}
|
||||
|
||||
@@ -416,14 +416,14 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage(
|
||||
if (application_language == std::nullopt) {
|
||||
LOG_ERROR(Service_NS, "Could not convert application language! language_code={}",
|
||||
language_code);
|
||||
return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
|
||||
return Service::NS::ResultApplicationLanguageNotFound;
|
||||
}
|
||||
const auto priority_list = GetApplicationLanguagePriorityList(*application_language);
|
||||
if (!priority_list) {
|
||||
LOG_ERROR(Service_NS,
|
||||
"Could not find application language priorities! application_language={}",
|
||||
*application_language);
|
||||
return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
|
||||
return Service::NS::ResultApplicationLanguageNotFound;
|
||||
}
|
||||
|
||||
// Try to find a valid language.
|
||||
@@ -436,7 +436,7 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage(
|
||||
|
||||
LOG_ERROR(Service_NS, "Could not find a valid language! supported_languages={:08X}",
|
||||
supported_languages);
|
||||
return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
|
||||
return Service::NS::ResultApplicationLanguageNotFound;
|
||||
}
|
||||
|
||||
void IApplicationManagerInterface::ConvertApplicationLanguageToLanguageCode(
|
||||
@@ -461,7 +461,7 @@ ResultVal<u64> IApplicationManagerInterface::ConvertApplicationLanguageToLanguag
|
||||
ConvertToLanguageCode(static_cast<ApplicationLanguage>(application_language));
|
||||
if (language_code == std::nullopt) {
|
||||
LOG_ERROR(Service_NS, "Language not found! application_language={}", application_language);
|
||||
return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
|
||||
return Service::NS::ResultApplicationLanguageNotFound;
|
||||
}
|
||||
|
||||
return static_cast<u64>(*language_code);
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
namespace Service::PSC {
|
||||
|
||||
class PSC_C final : public ServiceFramework<PSC_C> {
|
||||
class IPmControl final : public ServiceFramework<IPmControl> {
|
||||
public:
|
||||
explicit PSC_C(Core::System& system_) : ServiceFramework{system_, "psc:c"} {
|
||||
explicit IPmControl(Core::System& system_) : ServiceFramework{system_, "psc:c"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "Initialize"},
|
||||
@@ -23,8 +23,8 @@ public:
|
||||
{4, nullptr, "Cancel"},
|
||||
{5, nullptr, "PrintModuleInformation"},
|
||||
{6, nullptr, "GetModuleInformation"},
|
||||
{10, nullptr, "Unknown10"},
|
||||
{11, nullptr, "Unknown11"},
|
||||
{10, nullptr, "AcquireStateLock"},
|
||||
{11, nullptr, "HasStateLock"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -49,12 +49,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class PSC_M final : public ServiceFramework<PSC_M> {
|
||||
class IPmService final : public ServiceFramework<IPmService> {
|
||||
public:
|
||||
explicit PSC_M(Core::System& system_) : ServiceFramework{system_, "psc:m"} {
|
||||
explicit IPmService(Core::System& system_) : ServiceFramework{system_, "psc:m"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &PSC_M::GetPmModule, "GetPmModule"},
|
||||
{0, &IPmService::GetPmModule, "GetPmModule"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -74,8 +74,8 @@ private:
|
||||
void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
||||
server_manager->RegisterNamedService("psc:c", std::make_shared<PSC_C>(system));
|
||||
server_manager->RegisterNamedService("psc:m", std::make_shared<PSC_M>(system));
|
||||
server_manager->RegisterNamedService("psc:c", std::make_shared<IPmControl>(system));
|
||||
server_manager->RegisterNamedService("psc:m", std::make_shared<IPmService>(system));
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@ Result ServerManager::CompleteSyncRequest(RequestState&& request) {
|
||||
rc = request.session->SendReplyHLE();
|
||||
|
||||
// If the session has been closed, we're done.
|
||||
if (rc == Kernel::ResultSessionClosed || service_rc == IPC::ERR_REMOTE_PROCESS_DEAD) {
|
||||
if (rc == Kernel::ResultSessionClosed || service_rc == IPC::ResultSessionClosed) {
|
||||
// Close the session.
|
||||
request.session->Close();
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ Result ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session,
|
||||
case IPC::CommandType::TIPC_Close: {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
result = IPC::ERR_REMOTE_PROCESS_DEAD;
|
||||
result = IPC::ResultSessionClosed;
|
||||
break;
|
||||
}
|
||||
case IPC::CommandType::ControlWithContext:
|
||||
|
||||
@@ -74,7 +74,7 @@ constexpr std::array<std::pair<LanguageCode, KeyboardLayout>, 18> language_to_la
|
||||
constexpr std::size_t PRE_4_0_0_MAX_ENTRIES = 0xF;
|
||||
constexpr std::size_t POST_4_0_0_MAX_ENTRIES = 0x40;
|
||||
|
||||
constexpr Result ERR_INVALID_LANGUAGE{ErrorModule::Settings, 625};
|
||||
constexpr Result ResultInvalidLanguage{ErrorModule::Settings, 625};
|
||||
|
||||
void PushResponseLanguageCode(HLERequestContext& ctx, std::size_t num_language_codes) {
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
@@ -130,7 +130,7 @@ void SET::MakeLanguageCode(HLERequestContext& ctx) {
|
||||
if (index >= available_language_codes.size()) {
|
||||
LOG_ERROR(Service_SET, "Invalid language code index! index={}", index);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERR_INVALID_LANGUAGE);
|
||||
rb.Push(Set::ResultInvalidLanguage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
namespace Service::SM {
|
||||
|
||||
constexpr Result ERR_NOT_INITIALIZED(ErrorModule::SM, 2);
|
||||
constexpr Result ERR_ALREADY_REGISTERED(ErrorModule::SM, 4);
|
||||
constexpr Result ERR_INVALID_NAME(ErrorModule::SM, 6);
|
||||
constexpr Result ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7);
|
||||
constexpr Result ResultInvalidClient(ErrorModule::SM, 2);
|
||||
constexpr Result ResultAlreadyRegistered(ErrorModule::SM, 4);
|
||||
constexpr Result ResultInvalidServiceName(ErrorModule::SM, 6);
|
||||
constexpr Result ResultNotRegistered(ErrorModule::SM, 7);
|
||||
|
||||
ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} {
|
||||
controller_interface = std::make_unique<Controller>(kernel.System());
|
||||
@@ -45,7 +45,7 @@ void ServiceManager::InvokeControlRequest(HLERequestContext& context) {
|
||||
static Result ValidateServiceName(const std::string& name) {
|
||||
if (name.empty() || name.size() > 8) {
|
||||
LOG_ERROR(Service_SM, "Invalid service name! service={}", name);
|
||||
return ERR_INVALID_NAME;
|
||||
return Service::SM::ResultInvalidServiceName;
|
||||
}
|
||||
return ResultSuccess;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ Result ServiceManager::RegisterService(std::string name, u32 max_sessions,
|
||||
std::scoped_lock lk{lock};
|
||||
if (registered_services.find(name) != registered_services.end()) {
|
||||
LOG_ERROR(Service_SM, "Service is already registered! service={}", name);
|
||||
return ERR_ALREADY_REGISTERED;
|
||||
return Service::SM::ResultAlreadyRegistered;
|
||||
}
|
||||
|
||||
auto* port = Kernel::KPort::Create(kernel);
|
||||
@@ -80,7 +80,7 @@ Result ServiceManager::UnregisterService(const std::string& name) {
|
||||
const auto iter = registered_services.find(name);
|
||||
if (iter == registered_services.end()) {
|
||||
LOG_ERROR(Service_SM, "Server is not registered! service={}", name);
|
||||
return ERR_SERVICE_NOT_REGISTERED;
|
||||
return Service::SM::ResultNotRegistered;
|
||||
}
|
||||
|
||||
registered_services.erase(iter);
|
||||
@@ -96,7 +96,7 @@ ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name
|
||||
auto it = service_ports.find(name);
|
||||
if (it == service_ports.end()) {
|
||||
LOG_WARNING(Service_SM, "Server is not registered! service={}", name);
|
||||
return ERR_SERVICE_NOT_REGISTERED;
|
||||
return Service::SM::ResultNotRegistered;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
@@ -160,7 +160,7 @@ static std::string PopServiceName(IPC::RequestParser& rp) {
|
||||
|
||||
ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(HLERequestContext& ctx) {
|
||||
if (!ctx.GetManager()->GetIsInitializedForSm()) {
|
||||
return ERR_NOT_INITIALIZED;
|
||||
return Service::SM::ResultInvalidClient;
|
||||
}
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
@@ -168,15 +168,15 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(HLERequestContext& ctx) {
|
||||
|
||||
// Find the named port.
|
||||
auto port_result = service_manager.GetServicePort(name);
|
||||
if (port_result.Code() == ERR_INVALID_NAME) {
|
||||
if (port_result.Code() == Service::SM::ResultInvalidServiceName) {
|
||||
LOG_ERROR(Service_SM, "Invalid service name '{}'", name);
|
||||
return ERR_INVALID_NAME;
|
||||
return Service::SM::ResultInvalidServiceName;
|
||||
}
|
||||
|
||||
if (port_result.Failed()) {
|
||||
LOG_INFO(Service_SM, "Waiting for service {} to become available", name);
|
||||
ctx.SetIsDeferred();
|
||||
return ERR_SERVICE_NOT_REGISTERED;
|
||||
return Service::SM::ResultNotRegistered;
|
||||
}
|
||||
auto& port = port_result.Unwrap();
|
||||
|
||||
|
||||
@@ -8,14 +8,36 @@
|
||||
|
||||
namespace Service::SSL {
|
||||
|
||||
// This is nn::ssl::sf::CertificateFormat
|
||||
enum class CertificateFormat : u32 {
|
||||
Pem = 1,
|
||||
Der = 2,
|
||||
};
|
||||
|
||||
// This is nn::ssl::sf::ContextOption
|
||||
enum class ContextOption : u32 {
|
||||
None = 0,
|
||||
CrlImportDateCheckEnable = 1,
|
||||
};
|
||||
|
||||
// This is nn::ssl::sf::SslVersion
|
||||
struct SslVersion {
|
||||
union {
|
||||
u32 raw{};
|
||||
|
||||
BitField<0, 1, u32> tls_auto;
|
||||
BitField<3, 1, u32> tls_v10;
|
||||
BitField<4, 1, u32> tls_v11;
|
||||
BitField<5, 1, u32> tls_v12;
|
||||
BitField<6, 1, u32> tls_v13;
|
||||
BitField<24, 7, u32> api_version;
|
||||
};
|
||||
};
|
||||
|
||||
class ISslConnection final : public ServiceFramework<ISslConnection> {
|
||||
public:
|
||||
explicit ISslConnection(Core::System& system_) : ServiceFramework{system_, "ISslConnection"} {
|
||||
explicit ISslConnection(Core::System& system_, SslVersion version)
|
||||
: ServiceFramework{system_, "ISslConnection"}, ssl_version{version} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "SetSocketDescriptor"},
|
||||
@@ -59,11 +81,15 @@ public:
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
SslVersion ssl_version;
|
||||
};
|
||||
|
||||
class ISslContext final : public ServiceFramework<ISslContext> {
|
||||
public:
|
||||
explicit ISslContext(Core::System& system_) : ServiceFramework{system_, "ISslContext"} {
|
||||
explicit ISslContext(Core::System& system_, SslVersion version)
|
||||
: ServiceFramework{system_, "ISslContext"}, ssl_version{version} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ISslContext::SetOption, "SetOption"},
|
||||
{1, nullptr, "GetOption"},
|
||||
@@ -84,17 +110,20 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
SslVersion ssl_version;
|
||||
|
||||
void SetOption(HLERequestContext& ctx) {
|
||||
struct Parameters {
|
||||
u8 enable;
|
||||
u32 option;
|
||||
ContextOption option;
|
||||
s32 value;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x8, "Parameters is an invalid size");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto parameters = rp.PopRaw<Parameters>();
|
||||
|
||||
LOG_WARNING(Service_SSL, "(STUBBED) called. enable={}, option={}", parameters.enable,
|
||||
parameters.option);
|
||||
LOG_WARNING(Service_SSL, "(STUBBED) called. option={}, value={}", parameters.option,
|
||||
parameters.value);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -105,7 +134,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<ISslConnection>(system);
|
||||
rb.PushIpcInterface<ISslConnection>(system, ssl_version);
|
||||
}
|
||||
|
||||
void ImportServerPki(HLERequestContext& ctx) {
|
||||
@@ -142,20 +171,21 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
class SSL final : public ServiceFramework<SSL> {
|
||||
class ISslService final : public ServiceFramework<ISslService> {
|
||||
public:
|
||||
explicit SSL(Core::System& system_) : ServiceFramework{system_, "ssl"} {
|
||||
explicit ISslService(Core::System& system_) : ServiceFramework{system_, "ssl"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &SSL::CreateContext, "CreateContext"},
|
||||
{0, &ISslService::CreateContext, "CreateContext"},
|
||||
{1, nullptr, "GetContextCount"},
|
||||
{2, nullptr, "GetCertificates"},
|
||||
{3, nullptr, "GetCertificateBufSize"},
|
||||
{4, nullptr, "DebugIoctl"},
|
||||
{5, &SSL::SetInterfaceVersion, "SetInterfaceVersion"},
|
||||
{5, &ISslService::SetInterfaceVersion, "SetInterfaceVersion"},
|
||||
{6, nullptr, "FlushSessionCache"},
|
||||
{7, nullptr, "SetDebugOption"},
|
||||
{8, nullptr, "GetDebugOption"},
|
||||
{8, nullptr, "ClearTls12FallbackFlag"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -163,20 +193,30 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
u32 ssl_version{};
|
||||
void CreateContext(HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_SSL, "(STUBBED) called");
|
||||
struct Parameters {
|
||||
SslVersion ssl_version;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
u64 pid_placeholder;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x10, "Parameters is an invalid size");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto parameters = rp.PopRaw<Parameters>();
|
||||
|
||||
LOG_WARNING(Service_SSL, "(STUBBED) called, api_version={}, pid_placeholder={}",
|
||||
parameters.ssl_version.api_version, parameters.pid_placeholder);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<ISslContext>(system);
|
||||
rb.PushIpcInterface<ISslContext>(system, parameters.ssl_version);
|
||||
}
|
||||
|
||||
void SetInterfaceVersion(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SSL, "called");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
ssl_version = rp.Pop<u32>();
|
||||
u32 ssl_version = rp.Pop<u32>();
|
||||
|
||||
LOG_DEBUG(Service_SSL, "called, ssl_version={}", ssl_version);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
@@ -186,7 +226,7 @@ private:
|
||||
void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
||||
server_manager->RegisterNamedService("ssl", std::make_shared<SSL>(system));
|
||||
server_manager->RegisterNamedService("ssl", std::make_shared<ISslService>(system));
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,19 +16,19 @@ public:
|
||||
explicit IDsInterface(Core::System& system_) : ServiceFramework{system_, "IDsInterface"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "BindDevice"},
|
||||
{1, nullptr, "BindClientProcess"},
|
||||
{2, nullptr, "AddInterface"},
|
||||
{3, nullptr, "GetStateChangeEvent"},
|
||||
{4, nullptr, "GetState"},
|
||||
{5, nullptr, "ClearDeviceData"},
|
||||
{6, nullptr, "AddUsbStringDescriptor"},
|
||||
{7, nullptr, "DeleteUsbStringDescriptor"},
|
||||
{8, nullptr, "SetUsbDeviceDescriptor"},
|
||||
{9, nullptr, "SetBinaryObjectStore"},
|
||||
{10, nullptr, "Enable"},
|
||||
{11, nullptr, "Disable"},
|
||||
{12, nullptr, "Unknown12"},
|
||||
{0, nullptr, "AddEndpoint"},
|
||||
{1, nullptr, "GetSetupEvent"},
|
||||
{2, nullptr, "GetSetupPacket"},
|
||||
{3, nullptr, "Enable"},
|
||||
{4, nullptr, "Disable"},
|
||||
{5, nullptr, "CtrlIn"},
|
||||
{6, nullptr, "CtrlOut"},
|
||||
{7, nullptr, "GetCtrlInCompletionEvent"},
|
||||
{8, nullptr, "GetCtrlInUrbReport"},
|
||||
{9, nullptr, "GetCtrlOutCompletionEvent"},
|
||||
{10, nullptr, "GetCtrlOutUrbReport"},
|
||||
{11, nullptr, "CtrlStall"},
|
||||
{12, nullptr, "AppendConfigurationData"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -36,9 +36,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class USB_DS final : public ServiceFramework<USB_DS> {
|
||||
class IDsRootSession final : public ServiceFramework<IDsRootSession> {
|
||||
public:
|
||||
explicit USB_DS(Core::System& system_) : ServiceFramework{system_, "usb:ds"} {
|
||||
explicit IDsRootSession(Core::System& system_) : ServiceFramework{system_, "usb:ds"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "OpenDsService"},
|
||||
@@ -94,9 +94,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class USB_HS final : public ServiceFramework<USB_HS> {
|
||||
class IClientRootSession final : public ServiceFramework<IClientRootSession> {
|
||||
public:
|
||||
explicit USB_HS(Core::System& system_) : ServiceFramework{system_, "usb:hs"} {
|
||||
explicit IClientRootSession(Core::System& system_) : ServiceFramework{system_, "usb:hs"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "BindClientProcess"},
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
{5, nullptr, "DestroyInterfaceAvailableEvent"},
|
||||
{6, nullptr, "GetInterfaceStateChangeEvent"},
|
||||
{7, nullptr, "AcquireUsbIf"},
|
||||
{8, nullptr, "ResetDevice"},
|
||||
{8, nullptr, "SetTestMode"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -134,12 +134,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class USB_PD final : public ServiceFramework<USB_PD> {
|
||||
class IPdManager final : public ServiceFramework<IPdManager> {
|
||||
public:
|
||||
explicit USB_PD(Core::System& system_) : ServiceFramework{system_, "usb:pd"} {
|
||||
explicit IPdManager(Core::System& system_) : ServiceFramework{system_, "usb:pd"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &USB_PD::GetPdSession, "GetPdSession"},
|
||||
{0, &IPdManager::OpenSession, "OpenSession"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void GetPdSession(HLERequestContext& ctx) {
|
||||
void OpenSession(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_USB, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
@@ -178,12 +178,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class USB_PD_C final : public ServiceFramework<USB_PD_C> {
|
||||
class IPdCradleManager final : public ServiceFramework<IPdCradleManager> {
|
||||
public:
|
||||
explicit USB_PD_C(Core::System& system_) : ServiceFramework{system_, "usb:pd:c"} {
|
||||
explicit IPdCradleManager(Core::System& system_) : ServiceFramework{system_, "usb:pd:c"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &USB_PD_C::GetPdCradleSession, "GetPdCradleSession"},
|
||||
{0, &IPdCradleManager::OpenCradleSession, "OpenCradleSession"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -191,18 +191,18 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void GetPdCradleSession(HLERequestContext& ctx) {
|
||||
void OpenCradleSession(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_USB, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IPdCradleSession>(system);
|
||||
|
||||
LOG_DEBUG(Service_USB, "called");
|
||||
}
|
||||
};
|
||||
|
||||
class USB_PM final : public ServiceFramework<USB_PM> {
|
||||
class IPmMainService final : public ServiceFramework<IPmMainService> {
|
||||
public:
|
||||
explicit USB_PM(Core::System& system_) : ServiceFramework{system_, "usb:pm"} {
|
||||
explicit IPmMainService(Core::System& system_) : ServiceFramework{system_, "usb:pm"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "GetPowerEvent"},
|
||||
@@ -221,11 +221,11 @@ public:
|
||||
void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
||||
server_manager->RegisterNamedService("usb:ds", std::make_shared<USB_DS>(system));
|
||||
server_manager->RegisterNamedService("usb:hs", std::make_shared<USB_HS>(system));
|
||||
server_manager->RegisterNamedService("usb:pd", std::make_shared<USB_PD>(system));
|
||||
server_manager->RegisterNamedService("usb:pd:c", std::make_shared<USB_PD_C>(system));
|
||||
server_manager->RegisterNamedService("usb:pm", std::make_shared<USB_PM>(system));
|
||||
server_manager->RegisterNamedService("usb:ds", std::make_shared<IDsRootSession>(system));
|
||||
server_manager->RegisterNamedService("usb:hs", std::make_shared<IClientRootSession>(system));
|
||||
server_manager->RegisterNamedService("usb:pd", std::make_shared<IPdManager>(system));
|
||||
server_manager->RegisterNamedService("usb:pd:c", std::make_shared<IPdCradleManager>(system));
|
||||
server_manager->RegisterNamedService("usb:pm", std::make_shared<IPmMainService>(system));
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
||||
|
||||
@@ -307,8 +307,8 @@ Common::Input::DriverResult Joycons::SetPollingMode(const PadIdentifier& identif
|
||||
switch (polling_mode) {
|
||||
case Common::Input::PollingMode::Active:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetActiveMode());
|
||||
case Common::Input::PollingMode::Pasive:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetPasiveMode());
|
||||
case Common::Input::PollingMode::Passive:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetPassiveMode());
|
||||
case Common::Input::PollingMode::IR:
|
||||
return static_cast<Common::Input::DriverResult>(handle->SetIrMode());
|
||||
case Common::Input::PollingMode::NFC:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <thread>
|
||||
#include <fmt/format.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "common/param_package.h"
|
||||
#include "common/settings.h"
|
||||
@@ -11,8 +12,9 @@
|
||||
|
||||
namespace InputCommon {
|
||||
constexpr int update_time = 10;
|
||||
constexpr float default_stick_sensitivity = 0.022f;
|
||||
constexpr float default_motion_sensitivity = 0.008f;
|
||||
constexpr float default_stick_sensitivity = 0.0044f;
|
||||
constexpr float default_motion_sensitivity = 0.0003f;
|
||||
constexpr float maximum_rotation_speed = 2.0f;
|
||||
constexpr int mouse_axis_x = 0;
|
||||
constexpr int mouse_axis_y = 1;
|
||||
constexpr int wheel_axis_x = 2;
|
||||
@@ -99,11 +101,13 @@ void Mouse::UpdateMotionInput() {
|
||||
const float sensitivity =
|
||||
Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity;
|
||||
|
||||
// Slow movement by 7%
|
||||
if (Settings::values.mouse_panning) {
|
||||
last_motion_change *= 0.93f;
|
||||
} else {
|
||||
last_motion_change.z *= 0.93f;
|
||||
const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x +
|
||||
last_motion_change.y * last_motion_change.y);
|
||||
|
||||
if (rotation_velocity > maximum_rotation_speed / sensitivity) {
|
||||
const float multiplier = maximum_rotation_speed / rotation_velocity / sensitivity;
|
||||
last_motion_change.x = last_motion_change.x * multiplier;
|
||||
last_motion_change.y = last_motion_change.y * multiplier;
|
||||
}
|
||||
|
||||
const BasicMotion motion_data{
|
||||
@@ -116,6 +120,12 @@ void Mouse::UpdateMotionInput() {
|
||||
.delta_timestamp = update_time * 1000,
|
||||
};
|
||||
|
||||
if (Settings::values.mouse_panning) {
|
||||
last_motion_change.x = 0;
|
||||
last_motion_change.y = 0;
|
||||
}
|
||||
last_motion_change.z = 0;
|
||||
|
||||
SetMotion(motion_identifier, 0, motion_data);
|
||||
}
|
||||
|
||||
@@ -125,7 +135,7 @@ void Mouse::Move(int x, int y, int center_x, int center_y) {
|
||||
|
||||
auto mouse_change =
|
||||
(Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>();
|
||||
Common::Vec3<float> motion_change{-mouse_change.y, -mouse_change.x, last_motion_change.z};
|
||||
last_motion_change += {-mouse_change.y, -mouse_change.x, last_motion_change.z};
|
||||
|
||||
const auto move_distance = mouse_change.Length();
|
||||
if (move_distance == 0) {
|
||||
@@ -141,7 +151,6 @@ void Mouse::Move(int x, int y, int center_x, int center_y) {
|
||||
|
||||
// Average mouse movements
|
||||
last_mouse_change = (last_mouse_change * 0.91f) + (mouse_change * 0.09f);
|
||||
last_motion_change = (last_motion_change * 0.69f) + (motion_change * 0.31f);
|
||||
|
||||
const auto last_move_distance = last_mouse_change.Length();
|
||||
|
||||
|
||||
@@ -60,6 +60,6 @@ private:
|
||||
std::string file_path{};
|
||||
State state{State::Initialized};
|
||||
std::vector<u8> nfc_data;
|
||||
Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Pasive};
|
||||
Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Passive};
|
||||
};
|
||||
} // namespace InputCommon
|
||||
|
||||
@@ -410,7 +410,7 @@ DriverResult JoyconDriver::SetIrsConfig(IrsMode mode_, IrsResolution format_) {
|
||||
return result;
|
||||
}
|
||||
|
||||
DriverResult JoyconDriver::SetPasiveMode() {
|
||||
DriverResult JoyconDriver::SetPassiveMode() {
|
||||
std::scoped_lock lock{mutex};
|
||||
motion_enabled = false;
|
||||
hidbus_enabled = false;
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
DriverResult SetVibration(const VibrationValue& vibration);
|
||||
DriverResult SetLedConfig(u8 led_pattern);
|
||||
DriverResult SetIrsConfig(IrsMode mode_, IrsResolution format_);
|
||||
DriverResult SetPasiveMode();
|
||||
DriverResult SetPassiveMode();
|
||||
DriverResult SetActiveMode();
|
||||
DriverResult SetIrMode();
|
||||
DriverResult SetNfcMode();
|
||||
|
||||
@@ -78,7 +78,7 @@ enum class PadButton : u32 {
|
||||
Capture = 0x200000,
|
||||
};
|
||||
|
||||
enum class PasivePadButton : u32 {
|
||||
enum class PassivePadButton : u32 {
|
||||
Down_A = 0x0001,
|
||||
Right_X = 0x0002,
|
||||
Left_B = 0x0004,
|
||||
@@ -95,6 +95,18 @@ enum class PasivePadButton : u32 {
|
||||
ZL_ZR = 0x8000,
|
||||
};
|
||||
|
||||
enum class PassivePadStick : u8 {
|
||||
Right = 0x00,
|
||||
RightDown = 0x01,
|
||||
Down = 0x02,
|
||||
DownLeft = 0x03,
|
||||
Left = 0x04,
|
||||
LeftUp = 0x05,
|
||||
Up = 0x06,
|
||||
UpRight = 0x07,
|
||||
Neutral = 0x08,
|
||||
};
|
||||
|
||||
enum class OutputReport : u8 {
|
||||
RUMBLE_AND_SUBCMD = 0x01,
|
||||
FW_UPDATE_PKT = 0x03,
|
||||
|
||||
@@ -12,7 +12,7 @@ JoyconPoller::JoyconPoller(ControllerType device_type_, JoyStickCalibration left
|
||||
: device_type{device_type_}, left_stick_calibration{left_stick_calibration_},
|
||||
right_stick_calibration{right_stick_calibration_}, motion_calibration{motion_calibration_} {}
|
||||
|
||||
void JoyconPoller::SetCallbacks(const Joycon::JoyconCallbacks& callbacks_) {
|
||||
void JoyconPoller::SetCallbacks(const JoyconCallbacks& callbacks_) {
|
||||
callbacks = std::move(callbacks_);
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti
|
||||
memcpy(&data, buffer.data(), sizeof(InputReportActive));
|
||||
|
||||
switch (device_type) {
|
||||
case Joycon::ControllerType::Left:
|
||||
case ControllerType::Left:
|
||||
UpdateActiveLeftPadInput(data, motion_status);
|
||||
break;
|
||||
case Joycon::ControllerType::Right:
|
||||
case ControllerType::Right:
|
||||
UpdateActiveRightPadInput(data, motion_status);
|
||||
break;
|
||||
case Joycon::ControllerType::Pro:
|
||||
case ControllerType::Pro:
|
||||
UpdateActiveProPadInput(data, motion_status);
|
||||
break;
|
||||
default:
|
||||
@@ -47,14 +47,14 @@ void JoyconPoller::ReadPassiveMode(std::span<u8> buffer) {
|
||||
memcpy(&data, buffer.data(), sizeof(InputReportPassive));
|
||||
|
||||
switch (device_type) {
|
||||
case Joycon::ControllerType::Left:
|
||||
UpdatePasiveLeftPadInput(data);
|
||||
case ControllerType::Left:
|
||||
UpdatePassiveLeftPadInput(data);
|
||||
break;
|
||||
case Joycon::ControllerType::Right:
|
||||
UpdatePasiveRightPadInput(data);
|
||||
case ControllerType::Right:
|
||||
UpdatePassiveRightPadInput(data);
|
||||
break;
|
||||
case Joycon::ControllerType::Pro:
|
||||
UpdatePasiveProPadInput(data);
|
||||
case ControllerType::Pro:
|
||||
UpdatePassiveProPadInput(data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -210,14 +210,12 @@ void JoyconPoller::UpdateActiveProPadInput(const InputReportActive& input,
|
||||
}
|
||||
}
|
||||
|
||||
void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) {
|
||||
static constexpr std::array<Joycon::PasivePadButton, 11> left_buttons{
|
||||
Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X,
|
||||
Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y,
|
||||
Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR,
|
||||
Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR,
|
||||
Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Capture,
|
||||
Joycon::PasivePadButton::StickL,
|
||||
void JoyconPoller::UpdatePassiveLeftPadInput(const InputReportPassive& input) {
|
||||
static constexpr std::array<PassivePadButton, 11> left_buttons{
|
||||
PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B,
|
||||
PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR,
|
||||
PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Minus,
|
||||
PassivePadButton::Capture, PassivePadButton::StickL,
|
||||
};
|
||||
|
||||
for (auto left_button : left_buttons) {
|
||||
@@ -225,16 +223,19 @@ void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) {
|
||||
const int button = static_cast<int>(left_button);
|
||||
callbacks.on_button_data(button, button_status);
|
||||
}
|
||||
|
||||
const auto [left_axis_x, left_axis_y] =
|
||||
GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state));
|
||||
callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x);
|
||||
callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y);
|
||||
}
|
||||
|
||||
void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) {
|
||||
static constexpr std::array<Joycon::PasivePadButton, 11> right_buttons{
|
||||
Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X,
|
||||
Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y,
|
||||
Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR,
|
||||
Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR,
|
||||
Joycon::PasivePadButton::Plus, Joycon::PasivePadButton::Home,
|
||||
Joycon::PasivePadButton::StickR,
|
||||
void JoyconPoller::UpdatePassiveRightPadInput(const InputReportPassive& input) {
|
||||
static constexpr std::array<PassivePadButton, 11> right_buttons{
|
||||
PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B,
|
||||
PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR,
|
||||
PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Plus,
|
||||
PassivePadButton::Home, PassivePadButton::StickR,
|
||||
};
|
||||
|
||||
for (auto right_button : right_buttons) {
|
||||
@@ -242,17 +243,20 @@ void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) {
|
||||
const int button = static_cast<int>(right_button);
|
||||
callbacks.on_button_data(button, button_status);
|
||||
}
|
||||
|
||||
const auto [right_axis_x, right_axis_y] =
|
||||
GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state));
|
||||
callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x);
|
||||
callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y);
|
||||
}
|
||||
|
||||
void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) {
|
||||
static constexpr std::array<Joycon::PasivePadButton, 14> pro_buttons{
|
||||
Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X,
|
||||
Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y,
|
||||
Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR,
|
||||
Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR,
|
||||
Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Plus,
|
||||
Joycon::PasivePadButton::Capture, Joycon::PasivePadButton::Home,
|
||||
Joycon::PasivePadButton::StickL, Joycon::PasivePadButton::StickR,
|
||||
void JoyconPoller::UpdatePassiveProPadInput(const InputReportPassive& input) {
|
||||
static constexpr std::array<PassivePadButton, 14> pro_buttons{
|
||||
PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B,
|
||||
PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR,
|
||||
PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Minus,
|
||||
PassivePadButton::Plus, PassivePadButton::Capture, PassivePadButton::Home,
|
||||
PassivePadButton::StickL, PassivePadButton::StickR,
|
||||
};
|
||||
|
||||
for (auto pro_button : pro_buttons) {
|
||||
@@ -260,6 +264,15 @@ void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) {
|
||||
const int button = static_cast<int>(pro_button);
|
||||
callbacks.on_button_data(button, button_status);
|
||||
}
|
||||
|
||||
const auto [left_axis_x, left_axis_y] =
|
||||
GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state & 0xf));
|
||||
const auto [right_axis_x, right_axis_y] =
|
||||
GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state >> 4));
|
||||
callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x);
|
||||
callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y);
|
||||
callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x);
|
||||
callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y);
|
||||
}
|
||||
|
||||
f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const {
|
||||
@@ -270,6 +283,30 @@ f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration ca
|
||||
return value / calibration.min;
|
||||
}
|
||||
|
||||
std::pair<f32, f32> JoyconPoller::GetPassiveAxisValue(PassivePadStick raw_value) const {
|
||||
switch (raw_value) {
|
||||
case PassivePadStick::Right:
|
||||
return {1.0f, 0.0f};
|
||||
case PassivePadStick::RightDown:
|
||||
return {1.0f, -1.0f};
|
||||
case PassivePadStick::Down:
|
||||
return {0.0f, -1.0f};
|
||||
case PassivePadStick::DownLeft:
|
||||
return {-1.0f, -1.0f};
|
||||
case PassivePadStick::Left:
|
||||
return {-1.0f, 0.0f};
|
||||
case PassivePadStick::LeftUp:
|
||||
return {-1.0f, 1.0f};
|
||||
case PassivePadStick::Up:
|
||||
return {0.0f, 1.0f};
|
||||
case PassivePadStick::UpRight:
|
||||
return {1.0f, 1.0f};
|
||||
case PassivePadStick::Neutral:
|
||||
default:
|
||||
return {0.0f, 0.0f};
|
||||
}
|
||||
}
|
||||
|
||||
f32 JoyconPoller::GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal,
|
||||
AccelerometerSensitivity sensitivity) const {
|
||||
const f32 value = raw * (1.0f / (cal.scale - cal.offset)) * 4;
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
JoyStickCalibration right_stick_calibration_,
|
||||
MotionCalibration motion_calibration_);
|
||||
|
||||
void SetCallbacks(const Joycon::JoyconCallbacks& callbacks_);
|
||||
void SetCallbacks(const JoyconCallbacks& callbacks_);
|
||||
|
||||
/// Handles data from passive packages
|
||||
void ReadPassiveMode(std::span<u8> buffer);
|
||||
@@ -46,12 +46,15 @@ private:
|
||||
const MotionStatus& motion_status);
|
||||
void UpdateActiveProPadInput(const InputReportActive& input, const MotionStatus& motion_status);
|
||||
|
||||
void UpdatePasiveLeftPadInput(const InputReportPassive& buffer);
|
||||
void UpdatePasiveRightPadInput(const InputReportPassive& buffer);
|
||||
void UpdatePasiveProPadInput(const InputReportPassive& buffer);
|
||||
void UpdatePassiveLeftPadInput(const InputReportPassive& buffer);
|
||||
void UpdatePassiveRightPadInput(const InputReportPassive& buffer);
|
||||
void UpdatePassiveProPadInput(const InputReportPassive& buffer);
|
||||
|
||||
/// Returns a calibrated joystick axis from raw axis data
|
||||
f32 GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const;
|
||||
f32 GetAxisValue(u16 raw_value, JoyStickAxisCalibration calibration) const;
|
||||
|
||||
/// Returns a digital joystick axis from passive axis data
|
||||
std::pair<f32, f32> GetPassiveAxisValue(PassivePadStick raw_value) const;
|
||||
|
||||
/// Returns a calibrated accelerometer axis from raw motion data
|
||||
f32 GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal,
|
||||
@@ -75,7 +78,7 @@ private:
|
||||
JoyStickCalibration right_stick_calibration{};
|
||||
MotionCalibration motion_calibration{};
|
||||
|
||||
Joycon::JoyconCallbacks callbacks{};
|
||||
JoyconCallbacks callbacks{};
|
||||
};
|
||||
|
||||
} // namespace InputCommon::Joycon
|
||||
|
||||
@@ -146,6 +146,7 @@ void MappingFactory::RegisterMotion(const MappingData& data) {
|
||||
if (data.engine == "mouse") {
|
||||
new_input.Set("motion", 0);
|
||||
new_input.Set("pad", 1);
|
||||
new_input.Set("threshold", 0.001f);
|
||||
input_queue.Push(new_input);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ struct Bias {
|
||||
u32 index;
|
||||
u32 offset_begin;
|
||||
u32 offset_end;
|
||||
u32 alignment;
|
||||
};
|
||||
|
||||
using boost::container::flat_set;
|
||||
@@ -349,7 +350,8 @@ std::optional<StorageBufferAddr> Track(const IR::Value& value, const Bias* bias)
|
||||
.index = index.U32(),
|
||||
.offset = offset.U32(),
|
||||
};
|
||||
if (!Common::IsAligned(storage_buffer.offset, 16)) {
|
||||
const u32 alignment{bias ? bias->alignment : 8U};
|
||||
if (!Common::IsAligned(storage_buffer.offset, alignment)) {
|
||||
// The SSBO pointer has to be aligned
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -371,6 +373,7 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageInfo& info)
|
||||
.index = 0,
|
||||
.offset_begin = 0x110,
|
||||
.offset_end = 0x610,
|
||||
.alignment = 16,
|
||||
};
|
||||
// Track the low address of the instruction
|
||||
const std::optional<LowAddrInfo> low_addr_info{TrackLowAddress(&inst)};
|
||||
@@ -386,8 +389,11 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageInfo& info)
|
||||
storage_buffer = Track(low_addr, nullptr);
|
||||
if (!storage_buffer) {
|
||||
// If that also fails, use NVN fallbacks
|
||||
LOG_WARNING(Shader, "Storage buffer failed to track, using global memory fallbacks");
|
||||
return;
|
||||
}
|
||||
LOG_WARNING(Shader, "Storage buffer tracked without bias, index {} offset {}",
|
||||
storage_buffer->index, storage_buffer->offset);
|
||||
}
|
||||
// Collect storage buffer and the instruction
|
||||
if (IsGlobalMemoryWrite(inst)) {
|
||||
|
||||
@@ -383,7 +383,8 @@ private:
|
||||
|
||||
void NotifyBufferDeletion();
|
||||
|
||||
[[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, bool is_written = false) const;
|
||||
[[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
|
||||
bool is_written = false) const;
|
||||
|
||||
[[nodiscard]] TextureBufferBinding GetTextureBufferBinding(GPUVAddr gpu_addr, u32 size,
|
||||
PixelFormat format);
|
||||
@@ -802,7 +803,7 @@ void BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index,
|
||||
|
||||
const auto& cbufs = maxwell3d->state.shader_stages[stage];
|
||||
const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset;
|
||||
storage_buffers[stage][ssbo_index] = StorageBufferBinding(ssbo_addr, is_written);
|
||||
storage_buffers[stage][ssbo_index] = StorageBufferBinding(ssbo_addr, cbuf_index, is_written);
|
||||
}
|
||||
|
||||
template <class P>
|
||||
@@ -842,7 +843,7 @@ void BufferCache<P>::BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index,
|
||||
|
||||
const auto& cbufs = launch_desc.const_buffer_config;
|
||||
const GPUVAddr ssbo_addr = cbufs[cbuf_index].Address() + cbuf_offset;
|
||||
compute_storage_buffers[ssbo_index] = StorageBufferBinding(ssbo_addr, is_written);
|
||||
compute_storage_buffers[ssbo_index] = StorageBufferBinding(ssbo_addr, cbuf_index, is_written);
|
||||
}
|
||||
|
||||
template <class P>
|
||||
@@ -1988,11 +1989,26 @@ void BufferCache<P>::NotifyBufferDeletion() {
|
||||
|
||||
template <class P>
|
||||
typename BufferCache<P>::Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr,
|
||||
u32 cbuf_index,
|
||||
bool is_written) const {
|
||||
const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr);
|
||||
const u32 size = gpu_memory->Read<u32>(ssbo_addr + 8);
|
||||
const auto size = [&]() {
|
||||
const bool is_nvn_cbuf = cbuf_index == 0;
|
||||
// The NVN driver buffer (index 0) is known to pack the SSBO address followed by its size.
|
||||
if (is_nvn_cbuf) {
|
||||
return gpu_memory->Read<u32>(ssbo_addr + 8);
|
||||
}
|
||||
// Other titles (notably Doom Eternal) may use STG/LDG on buffer addresses in custom defined
|
||||
// cbufs, which do not store the sizes adjacent to the addresses, so use the fully
|
||||
// mapped buffer size for now.
|
||||
const u32 memory_layout_size = static_cast<u32>(gpu_memory->GetMemoryLayoutSize(gpu_addr));
|
||||
LOG_INFO(HW_GPU, "Binding storage buffer for cbuf index {}, MemoryLayoutSize 0x{:X}",
|
||||
cbuf_index, memory_layout_size);
|
||||
return memory_layout_size;
|
||||
}();
|
||||
const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr);
|
||||
if (!cpu_addr || size == 0) {
|
||||
LOG_WARNING(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index);
|
||||
return NULL_BINDING;
|
||||
}
|
||||
const VAddr cpu_end = Common::AlignUp(*cpu_addr + size, Core::Memory::YUZU_PAGESIZE);
|
||||
|
||||
@@ -197,7 +197,7 @@ struct GPU::Impl {
|
||||
constexpr u64 gpu_ticks_num = 384;
|
||||
constexpr u64 gpu_ticks_den = 625;
|
||||
|
||||
u64 nanoseconds = system.CoreTiming().GetGlobalTimeNs().count();
|
||||
u64 nanoseconds = system.CoreTiming().GetCPUTimeNs().count();
|
||||
if (Settings::values.use_fast_gpu_time.GetValue()) {
|
||||
nanoseconds /= 256;
|
||||
}
|
||||
|
||||
@@ -112,13 +112,17 @@ GLenum ImageTarget(Shader::TextureType type, int num_samples = 1) {
|
||||
return GL_NONE;
|
||||
}
|
||||
|
||||
GLenum TextureMode(PixelFormat format, bool is_first) {
|
||||
GLenum TextureMode(PixelFormat format, std::array<SwizzleSource, 4> swizzle) {
|
||||
bool any_r =
|
||||
std::ranges::any_of(swizzle, [](SwizzleSource s) { return s == SwizzleSource::R; });
|
||||
switch (format) {
|
||||
case PixelFormat::D24_UNORM_S8_UINT:
|
||||
case PixelFormat::D32_FLOAT_S8_UINT:
|
||||
return is_first ? GL_DEPTH_COMPONENT : GL_STENCIL_INDEX;
|
||||
// R = depth, G = stencil
|
||||
return any_r ? GL_DEPTH_COMPONENT : GL_STENCIL_INDEX;
|
||||
case PixelFormat::S8_UINT_D24_UNORM:
|
||||
return is_first ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;
|
||||
// R = stencil, G = depth
|
||||
return any_r ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;
|
||||
default:
|
||||
ASSERT(false);
|
||||
return GL_DEPTH_COMPONENT;
|
||||
@@ -208,8 +212,7 @@ void ApplySwizzle(GLuint handle, PixelFormat format, std::array<SwizzleSource, 4
|
||||
case PixelFormat::D32_FLOAT_S8_UINT:
|
||||
case PixelFormat::S8_UINT_D24_UNORM:
|
||||
UNIMPLEMENTED_IF(swizzle[0] != SwizzleSource::R && swizzle[0] != SwizzleSource::G);
|
||||
glTextureParameteri(handle, GL_DEPTH_STENCIL_TEXTURE_MODE,
|
||||
TextureMode(format, swizzle[0] == SwizzleSource::R));
|
||||
glTextureParameteri(handle, GL_DEPTH_STENCIL_TEXTURE_MODE, TextureMode(format, swizzle));
|
||||
std::ranges::transform(swizzle, swizzle.begin(), ConvertGreenRed);
|
||||
break;
|
||||
case PixelFormat::A5B5G5R1_UNORM: {
|
||||
|
||||
@@ -238,7 +238,7 @@ private:
|
||||
return indices;
|
||||
}
|
||||
|
||||
void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) {
|
||||
void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) override {
|
||||
switch (index_type) {
|
||||
case VK_INDEX_TYPE_UINT8_EXT:
|
||||
std::memcpy(staging_data, MakeIndices<u8>(quad, first).data(), quad_size);
|
||||
@@ -278,7 +278,7 @@ private:
|
||||
return indices;
|
||||
}
|
||||
|
||||
void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) {
|
||||
void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) override {
|
||||
switch (index_type) {
|
||||
case VK_INDEX_TYPE_UINT8_EXT:
|
||||
std::memcpy(staging_data, MakeIndices<u8>(quad, first).data(), quad_size);
|
||||
|
||||
@@ -1294,7 +1294,7 @@ void RasterizerVulkan::UpdateDepthBoundsTestEnable(Tegra::Engines::Maxwell3D::Re
|
||||
LOG_WARNING(Render_Vulkan, "Depth bounds is enabled but not supported");
|
||||
enabled = false;
|
||||
}
|
||||
scheduler.Record([enable = regs.depth_bounds_enable](vk::CommandBuffer cmdbuf) {
|
||||
scheduler.Record([enable = enabled](vk::CommandBuffer cmdbuf) {
|
||||
cmdbuf.SetDepthBoundsTestEnableEXT(enable);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,14 +47,15 @@ Scheduler::Scheduler(const Device& device_, StateTracker& state_tracker_)
|
||||
Scheduler::~Scheduler() = default;
|
||||
|
||||
void Scheduler::Flush(VkSemaphore signal_semaphore, VkSemaphore wait_semaphore) {
|
||||
// When flushing, we only send data to the worker thread; no waiting is necessary.
|
||||
SubmitExecution(signal_semaphore, wait_semaphore);
|
||||
AllocateNewContext();
|
||||
}
|
||||
|
||||
void Scheduler::Finish(VkSemaphore signal_semaphore, VkSemaphore wait_semaphore) {
|
||||
// When finishing, we need to wait for the submission to have executed on the device.
|
||||
const u64 presubmit_tick = CurrentTick();
|
||||
SubmitExecution(signal_semaphore, wait_semaphore);
|
||||
WaitWorker();
|
||||
Wait(presubmit_tick);
|
||||
AllocateNewContext();
|
||||
}
|
||||
@@ -63,8 +64,13 @@ void Scheduler::WaitWorker() {
|
||||
MICROPROFILE_SCOPE(Vulkan_WaitForWorker);
|
||||
DispatchWork();
|
||||
|
||||
std::unique_lock lock{work_mutex};
|
||||
wait_cv.wait(lock, [this] { return work_queue.empty(); });
|
||||
// Ensure the queue is drained.
|
||||
std::unique_lock ql{queue_mutex};
|
||||
event_cv.wait(ql, [this] { return work_queue.empty(); });
|
||||
|
||||
// Now wait for execution to finish.
|
||||
// This needs to be done in the same order as WorkerThread.
|
||||
std::unique_lock el{execution_mutex};
|
||||
}
|
||||
|
||||
void Scheduler::DispatchWork() {
|
||||
@@ -72,10 +78,10 @@ void Scheduler::DispatchWork() {
|
||||
return;
|
||||
}
|
||||
{
|
||||
std::scoped_lock lock{work_mutex};
|
||||
std::scoped_lock ql{queue_mutex};
|
||||
work_queue.push(std::move(chunk));
|
||||
}
|
||||
work_cv.notify_one();
|
||||
event_cv.notify_all();
|
||||
AcquireNewChunk();
|
||||
}
|
||||
|
||||
@@ -137,30 +143,55 @@ bool Scheduler::UpdateRescaling(bool is_rescaling) {
|
||||
|
||||
void Scheduler::WorkerThread(std::stop_token stop_token) {
|
||||
Common::SetCurrentThreadName("VulkanWorker");
|
||||
do {
|
||||
std::unique_ptr<CommandChunk> work;
|
||||
bool has_submit{false};
|
||||
{
|
||||
std::unique_lock lock{work_mutex};
|
||||
if (work_queue.empty()) {
|
||||
wait_cv.notify_all();
|
||||
}
|
||||
Common::CondvarWait(work_cv, lock, stop_token, [&] { return !work_queue.empty(); });
|
||||
if (stop_token.stop_requested()) {
|
||||
continue;
|
||||
}
|
||||
work = std::move(work_queue.front());
|
||||
work_queue.pop();
|
||||
|
||||
has_submit = work->HasSubmit();
|
||||
const auto TryPopQueue{[this](auto& work) -> bool {
|
||||
if (work_queue.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
work = std::move(work_queue.front());
|
||||
work_queue.pop();
|
||||
event_cv.notify_all();
|
||||
return true;
|
||||
}};
|
||||
|
||||
while (!stop_token.stop_requested()) {
|
||||
std::unique_ptr<CommandChunk> work;
|
||||
|
||||
{
|
||||
std::unique_lock lk{queue_mutex};
|
||||
|
||||
// Wait for work.
|
||||
Common::CondvarWait(event_cv, lk, stop_token, [&] { return TryPopQueue(work); });
|
||||
|
||||
// If we've been asked to stop, we're done.
|
||||
if (stop_token.stop_requested()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Exchange lock ownership so that we take the execution lock before
|
||||
// the queue lock goes out of scope. This allows us to force execution
|
||||
// to complete in the next step.
|
||||
std::exchange(lk, std::unique_lock{execution_mutex});
|
||||
|
||||
// Perform the work, tracking whether the chunk was a submission
|
||||
// before executing.
|
||||
const bool has_submit = work->HasSubmit();
|
||||
work->ExecuteAll(current_cmdbuf);
|
||||
|
||||
// If the chunk was a submission, reallocate the command buffer.
|
||||
if (has_submit) {
|
||||
AllocateWorkerCommandBuffer();
|
||||
}
|
||||
}
|
||||
if (has_submit) {
|
||||
AllocateWorkerCommandBuffer();
|
||||
|
||||
{
|
||||
std::scoped_lock rl{reserve_mutex};
|
||||
|
||||
// Recycle the chunk back to the reserve.
|
||||
chunk_reserve.emplace_back(std::move(work));
|
||||
}
|
||||
std::scoped_lock reserve_lock{reserve_mutex};
|
||||
chunk_reserve.push_back(std::move(work));
|
||||
} while (!stop_token.stop_requested());
|
||||
}
|
||||
}
|
||||
|
||||
void Scheduler::AllocateWorkerCommandBuffer() {
|
||||
@@ -289,13 +320,16 @@ void Scheduler::EndRenderPass() {
|
||||
}
|
||||
|
||||
void Scheduler::AcquireNewChunk() {
|
||||
std::scoped_lock lock{reserve_mutex};
|
||||
std::scoped_lock rl{reserve_mutex};
|
||||
|
||||
if (chunk_reserve.empty()) {
|
||||
// If we don't have anything reserved, we need to make a new chunk.
|
||||
chunk = std::make_unique<CommandChunk>();
|
||||
return;
|
||||
} else {
|
||||
// Otherwise, we can just take from the reserve.
|
||||
chunk = std::make_unique<CommandChunk>();
|
||||
chunk_reserve.pop_back();
|
||||
}
|
||||
chunk = std::move(chunk_reserve.back());
|
||||
chunk_reserve.pop_back();
|
||||
}
|
||||
|
||||
} // namespace Vulkan
|
||||
|
||||
@@ -232,10 +232,10 @@ private:
|
||||
|
||||
std::queue<std::unique_ptr<CommandChunk>> work_queue;
|
||||
std::vector<std::unique_ptr<CommandChunk>> chunk_reserve;
|
||||
std::mutex execution_mutex;
|
||||
std::mutex reserve_mutex;
|
||||
std::mutex work_mutex;
|
||||
std::condition_variable_any work_cv;
|
||||
std::condition_variable wait_cv;
|
||||
std::mutex queue_mutex;
|
||||
std::condition_variable_any event_cv;
|
||||
std::jthread worker_thread;
|
||||
};
|
||||
|
||||
|
||||
@@ -189,13 +189,16 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
||||
if (info.IsRenderTarget()) {
|
||||
return ImageAspectMask(info.format);
|
||||
}
|
||||
const bool is_first = info.Swizzle()[0] == SwizzleSource::R;
|
||||
bool any_r =
|
||||
std::ranges::any_of(info.Swizzle(), [](SwizzleSource s) { return s == SwizzleSource::R; });
|
||||
switch (info.format) {
|
||||
case PixelFormat::D24_UNORM_S8_UINT:
|
||||
case PixelFormat::D32_FLOAT_S8_UINT:
|
||||
return is_first ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
// R = depth, G = stencil
|
||||
return any_r ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
case PixelFormat::S8_UINT_D24_UNORM:
|
||||
return is_first ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
// R = stencil, G = depth
|
||||
return any_r ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
case PixelFormat::D16_UNORM:
|
||||
case PixelFormat::D32_FLOAT:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
@@ -1769,7 +1772,7 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t
|
||||
.minLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.0f : tsc.MinLod(),
|
||||
.maxLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.25f : tsc.MaxLod(),
|
||||
.borderColor =
|
||||
arbitrary_borders ? VK_BORDER_COLOR_INT_CUSTOM_EXT : ConvertBorderColor(color),
|
||||
arbitrary_borders ? VK_BORDER_COLOR_FLOAT_CUSTOM_EXT : ConvertBorderColor(color),
|
||||
.unnormalizedCoordinates = VK_FALSE,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,6 +91,9 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
||||
#include "common/microprofile.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "common/scope_exit.h"
|
||||
#ifdef _WIN32
|
||||
#include "common/windows/timer_resolution.h"
|
||||
#endif
|
||||
#ifdef ARCHITECTURE_x86_64
|
||||
#include "common/x64/cpu_detect.h"
|
||||
#endif
|
||||
@@ -377,6 +380,12 @@ GMainWindow::GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan
|
||||
LOG_INFO(Frontend, "Host RAM: {:.2f} GiB",
|
||||
Common::GetMemInfo().TotalPhysicalMemory / f64{1_GiB});
|
||||
LOG_INFO(Frontend, "Host Swap: {:.2f} GiB", Common::GetMemInfo().TotalSwapMemory / f64{1_GiB});
|
||||
#ifdef _WIN32
|
||||
LOG_INFO(Frontend, "Host Timer Resolution: {:.4f} ms",
|
||||
std::chrono::duration_cast<std::chrono::duration<f64, std::milli>>(
|
||||
Common::Windows::SetCurrentTimerResolutionToMaximum())
|
||||
.count());
|
||||
#endif
|
||||
UpdateWindowTitle();
|
||||
|
||||
show();
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <shellapi.h>
|
||||
|
||||
#include "common/windows/timer_resolution.h"
|
||||
#endif
|
||||
|
||||
#undef _UNICODE
|
||||
@@ -314,6 +316,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
#ifdef _WIN32
|
||||
LocalFree(argv_w);
|
||||
|
||||
Common::Windows::SetCurrentTimerResolutionToMaximum();
|
||||
#endif
|
||||
|
||||
MicroProfileOnThreadCreate("EmuThread");
|
||||
|
||||
Reference in New Issue
Block a user