Compare commits

..

1 Commits

Author SHA1 Message Date
Narr the Reg
3c1092dd59 input_common: Minor typo issues 2023-03-07 19:49:08 -06:00
58 changed files with 245 additions and 336 deletions

View File

@@ -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::ResultOutOfSessions;
return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED;
}
session_id = session_ids[next_session_id];
next_session_id = (next_session_id + 1) % MaxInSessions;

View File

@@ -19,7 +19,7 @@ void AudioManager::Shutdown() {
Result AudioManager::SetOutManager(BufferEventFunc buffer_func) {
if (!running) {
return Service::Audio::ResultOperationFailed;
return Service::Audio::ERR_OPERATION_FAILED;
}
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::ResultOperationFailed;
return Service::Audio::ERR_OPERATION_FAILED;
}
std::scoped_lock l{lock};

View File

@@ -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::ResultOutOfSessions;
return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED;
}
session_id = session_ids[next_session_id];
next_session_id = (next_session_id + 1) % MaxOutSessions;

View File

@@ -28,7 +28,7 @@ SystemManager& Manager::GetSystemManager() {
Result Manager::GetWorkBufferSize(const AudioRendererParameterInternal& params,
u64& out_count) const {
if (!CheckValidRevision(params.revision)) {
return Service::Audio::ResultInvalidRevision;
return Service::Audio::ERR_INVALID_REVISION;
}
out_count = System::GetWorkBufferSize(params);

View File

@@ -46,7 +46,7 @@ Result In::AppendBuffer(const AudioInBuffer& buffer, u64 tag) {
if (system.AppendBuffer(buffer, tag)) {
return ResultSuccess;
}
return Service::Audio::ResultBufferCountReached;
return Service::Audio::ERR_BUFFER_COUNT_EXCEEDED;
}
void In::ReleaseAndRegisterBuffers() {

View File

@@ -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::ResultNotFound;
return Service::Audio::ERR_INVALID_DEVICE_NAME;
}
if (in_params.sample_rate != TargetSampleRate && in_params.sample_rate > 0) {
return Service::Audio::ResultInvalidSampleRate;
return Service::Audio::ERR_INVALID_SAMPLE_RATE;
}
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::ResultOperationFailed;
return Service::Audio::ERR_OPERATION_FAILED;
}
session->Initialize(name, sample_format, channel_count, session_id, handle,

View File

@@ -46,7 +46,7 @@ Result Out::AppendBuffer(const AudioOutBuffer& buffer, const u64 tag) {
if (system.AppendBuffer(buffer, tag)) {
return ResultSuccess;
}
return Service::Audio::ResultBufferCountReached;
return Service::Audio::ERR_BUFFER_COUNT_EXCEEDED;
}
void Out::ReleaseAndRegisterBuffers() {

View File

@@ -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::ResultNotFound;
return Service::Audio::ERR_INVALID_DEVICE_NAME;
}
if (in_params.sample_rate != TargetSampleRate && in_params.sample_rate > 0) {
return Service::Audio::ResultInvalidSampleRate;
return Service::Audio::ERR_INVALID_SAMPLE_RATE;
}
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::ResultInvalidChannelCount;
return Service::Audio::ERR_INVALID_CHANNEL_COUNT;
}
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::ResultOperationFailed;
return Service::Audio::ERR_OPERATION_FAILED;
}
session->Initialize(name, sample_format, channel_count, session_id, handle,

View File

@@ -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::ResultOutOfSessions;
return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED;
}
system_registered = true;
}

View File

@@ -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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
}
}
if (total_buffer_count > mix_buffer_count) {
return Service::Audio::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
} 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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
}
@@ -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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
if (in_params->revision != behaviour_.GetUserRevision()) {
return Service::Audio::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
behaviour_.ClearError();
behaviour_.UpdateFlags(in_params->flags);
if (in_header->behaviour_size != sizeof(BehaviorInfo::InParameter)) {
return Service::Audio::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
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::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
} else if (CpuAddr(output) - CpuAddr(output_origin.data()) != expected_output_size) {
return Service::Audio::ResultInvalidUpdateInfo;
return Service::Audio::ERR_INVALID_UPDATE_DATA;
}
return ResultSuccess;
}

View File

@@ -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::ResultInvalidAddressInfo;
error_info.error_code = Service::Audio::ERR_POOL_MAPPING_FAILED;
error_info.address = address;
return force_map;
}

View File

@@ -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::ResultInvalidRevision;
return Service::Audio::ERR_INVALID_REVISION;
}
if (GetWorkBufferSize(params) > transfer_memory_size) {
return Service::Audio::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
if (process_handle_ == 0) {
return Service::Audio::ResultInvalidHandle;
return Service::Audio::ERR_INVALID_PROCESS_HANDLE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
auto upsampler_workbuffer{allocator.Allocate<s32>(
(voice_channels + mix_buffer_count) * TargetSampleCount * upsampler_count, 0x10)};
if (upsampler_workbuffer.empty()) {
return Service::Audio::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
depop_buffer =
allocator.Allocate<s32>(Common::AlignUp(static_cast<u32>(mix_buffer_count), 0x40), 0x40);
if (depop_buffer.empty()) {
return Service::Audio::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
// invalidate samples_workbuffer DSP cache
@@ -166,12 +166,12 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
}
if (voice_infos.empty()) {
return Service::Audio::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
auto sorted_voice_infos{allocator.Allocate<VoiceInfo*>(params.voices, 0x10)};
if (sorted_voice_infos.empty()) {
return Service::Audio::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
auto voice_cpu_states{allocator.Allocate<VoiceState>(params.voices, 0x10)};
if (voice_cpu_states.empty()) {
return Service::Audio::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
}
@@ -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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
if (!splitter_context.Initialize(behavior, params, allocator)) {
return Service::Audio::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
sink_context.Initialize(sinks, params.sinks);
auto voice_dsp_states{allocator.Allocate<VoiceState>(params.voices, 0x40)};
if (voice_dsp_states.empty()) {
return Service::Audio::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
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::ResultInsufficientBuffer;
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
}
command_buffer_size = 0;

View File

@@ -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::ResultInvalidUpdateInfo;
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
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::ResultInvalidUpdateInfo;
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
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::ResultInvalidUpdateInfo;
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
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::ResultInvalidUpdateInfo;
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
error_info[0].address = wave_buffer_internal.address;
return;
}

View File

@@ -91,7 +91,6 @@ 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

View File

@@ -3,21 +3,19 @@
#pragma once
#include <version>
#ifdef __cpp_lib_bit_cast
#include <bit>
#endif
#include <cstring>
#include <type_traits>
namespace Common {
template <typename To, typename From>
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
[[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;
}
} // namespace Common

View File

@@ -1,22 +0,0 @@
// 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

View File

@@ -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{50, 1, 100, "mouse_panning_sensitivity"};
Setting<u8, true> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"};
Setting<bool> mouse_enabled{false, "mouse_enabled"};
Setting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"};

View File

@@ -454,6 +454,7 @@ 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

View File

@@ -44,11 +44,11 @@ const KAddressSpaceInfo& GetAddressSpaceInfo(size_t width, KAddressSpaceInfo::Ty
} // namespace
std::size_t KAddressSpaceInfo::GetAddressSpaceStart(size_t width, KAddressSpaceInfo::Type type) {
uintptr_t KAddressSpaceInfo::GetAddressSpaceStart(size_t width, KAddressSpaceInfo::Type type) {
return GetAddressSpaceInfo(width, type).address;
}
std::size_t KAddressSpaceInfo::GetAddressSpaceSize(size_t width, KAddressSpaceInfo::Type type) {
size_t KAddressSpaceInfo::GetAddressSpaceSize(size_t width, KAddressSpaceInfo::Type type) {
return GetAddressSpaceInfo(width, type).size;
}

View File

@@ -18,7 +18,7 @@ struct KAddressSpaceInfo final {
Count,
};
static std::size_t GetAddressSpaceStart(std::size_t width, Type type);
static u64 GetAddressSpaceStart(std::size_t width, Type type);
static std::size_t GetAddressSpaceSize(std::size_t width, Type type);
const std::size_t bit_width{};

View File

@@ -21,9 +21,9 @@ public:
~KDeviceAddressSpace();
Result Initialize(u64 address, u64 size);
void Finalize() override;
void Finalize();
bool IsInitialized() const override {
bool IsInitialized() const {
return m_is_initialized;
}
static void PostDestroy(uintptr_t arg) {}

View File

@@ -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 ResultInvalidState will be returned.
/// terminated process, then ERR_INVALID_STATE will be returned.
///
/// @pre The process must be in a signaled state. If this is called on a
/// process instance that is not signaled, ResultInvalidState will be
/// process instance that is not signaled, ERR_INVALID_STATE will be
/// returned.
Result Reset();

View File

@@ -2,7 +2,6 @@
// 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"
@@ -105,7 +104,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 (Common::WrappingAdd(current_values[index], value) <= current_values[index]) {
if (current_values[index] + value <= current_values[index]) {
break;
}

View File

@@ -49,7 +49,6 @@ 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,
@@ -59,8 +58,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
@@ -816,27 +815,6 @@ 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);

View File

@@ -254,8 +254,6 @@ public:
thread_context_32.tpidr = static_cast<u32>(value);
}
void CloneFpuStatus();
[[nodiscard]] ThreadContext32& GetContext32() {
return thread_context_32;
}

View File

@@ -48,15 +48,19 @@ Result ResetSignal(Core::System& system, Handle handle) {
return ResultInvalidHandle;
}
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 <= Svc::ArgumentHandleCountMax, ResultOutOfRange);
/// 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);
// Ensure number of handles is valid.
R_UNLESS(0 <= num_handles && num_handles <= 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) {
@@ -64,38 +68,21 @@ static Result WaitSynchronization(Core::System& system, int32_t* out_index, cons
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 (auto i = 0; i < num_handles; ++i) {
for (s32 i = 0; i < num_handles; ++i) {
kernel.UnregisterInUseObject(objs[i]);
objs[i]->Close();
}
});
// 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));
return KSynchronizationObject::Wait(kernel, index, objs.data(), static_cast<s32>(objs.size()),
nano_seconds);
}
/// Resumes a thread waiting on WaitSynchronization

View File

@@ -82,9 +82,6 @@ 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);

View File

@@ -30,6 +30,12 @@
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;
@@ -378,7 +384,7 @@ protected:
if (user_data.size() < sizeof(UserData)) {
LOG_ERROR(Service_ACC, "UserData buffer too small!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(Account::ResultInvalidArrayLength);
rb.Push(ERR_INVALID_BUFFER);
return;
}
@@ -388,7 +394,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(Account::ResultAccountUpdateFailed);
rb.Push(ERR_FAILED_SAVE_DATA);
return;
}
@@ -411,7 +417,7 @@ protected:
if (user_data.size() < sizeof(UserData)) {
LOG_ERROR(Service_ACC, "UserData buffer too small!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(Account::ResultInvalidArrayLength);
rb.Push(ERR_INVALID_BUFFER);
return;
}
@@ -426,7 +432,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(Account::ResultAccountUpdateFailed);
rb.Push(ERR_FAILED_SAVE_DATA);
return;
}
@@ -758,7 +764,7 @@ void Module::Interface::InitializeApplicationInfoRestricted(HLERequestContext& c
Result Module::Interface::InitializeApplicationInfoBase() {
if (application_info) {
LOG_ERROR(Service_ACC, "Application already initialized");
return Account::ResultApplicationInfoAlreadyInitialized;
return ERR_ACCOUNTINFO_ALREADY_INITIALIZED;
}
// TODO(ogniK): This should be changed to reflect the target process for when we have multiple
@@ -769,7 +775,7 @@ Result Module::Interface::InitializeApplicationInfoBase() {
if (launch_property.Failed()) {
LOG_ERROR(Service_ACC, "Failed to get launch property");
return Account::ResultInvalidApplication;
return ERR_ACCOUNTINFO_BAD_APPLICATION;
}
switch (launch_property->base_game_storage_id) {
@@ -785,7 +791,7 @@ Result Module::Interface::InitializeApplicationInfoBase() {
default:
LOG_ERROR(Service_ACC, "Invalid game storage ID! storage_id={}",
launch_property->base_game_storage_id);
return Account::ResultInvalidApplication;
return ERR_ACCOUNTINFO_BAD_APPLICATION;
}
LOG_WARNING(Service_ACC, "ApplicationInfo init required");
@@ -893,20 +899,20 @@ void Module::Interface::StoreSaveDataThumbnail(HLERequestContext& ctx, const Com
if (tid == 0) {
LOG_ERROR(Service_ACC, "TitleID is not valid!");
rb.Push(Account::ResultInvalidApplication);
rb.Push(ERR_INVALID_APPLICATION_ID);
return;
}
if (uuid.IsInvalid()) {
LOG_ERROR(Service_ACC, "User ID is not valid!");
rb.Push(Account::ResultInvalidUserId);
rb.Push(ERR_INVALID_USER_ID);
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(Account::ResultInvalidArrayLength);
rb.Push(ERR_INVALID_BUFFER_SIZE);
return;
}

View File

@@ -7,13 +7,7 @@
namespace Service::Account {
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};
constexpr Result ERR_ACCOUNTINFO_BAD_APPLICATION{ErrorModule::Account, 22};
constexpr Result ERR_ACCOUNTINFO_ALREADY_INITIALIZED{ErrorModule::Account, 41};
} // namespace Service::Account

View File

@@ -39,9 +39,9 @@
namespace Service::AM {
constexpr Result ResultNoDataInChannel{ErrorModule::AM, 2};
constexpr Result ResultNoMessages{ErrorModule::AM, 3};
constexpr Result ResultInvalidOffset{ErrorModule::AM, 503};
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};
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(AM::ResultNoMessages);
rb.Push(ERR_NO_MESSAGES);
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(AM::ResultNoDataInChannel);
rb.Push(ERR_NO_DATA_IN_CHANNEL);
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(AM::ResultNoDataInChannel);
rb.Push(ERR_NO_DATA_IN_CHANNEL);
return;
}
@@ -1138,7 +1138,7 @@ void IStorageAccessor::Write(HLERequestContext& ctx) {
backing.GetSize(), size, offset);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(AM::ResultInvalidOffset);
rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
return;
}
@@ -1161,7 +1161,7 @@ void IStorageAccessor::Read(HLERequestContext& ctx) {
backing.GetSize(), size, offset);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(AM::ResultInvalidOffset);
rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
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(AM::ResultNoDataInChannel);
rb.Push(ERR_NO_DATA_IN_CHANNEL);
}
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(AM::ResultNoDataInChannel);
rb.Push(ERR_NO_DATA_IN_CHANNEL);
}
void IApplicationFunctions::GetNotificationStorageChannelEvent(HLERequestContext& ctx) {

View File

@@ -19,9 +19,10 @@
namespace Service::AM::Applets {
[[maybe_unused]] constexpr Result ResultControllerSupportCanceled{ErrorModule::HID, 3101};
[[maybe_unused]] constexpr Result ResultControllerSupportNotSupportedNpadStyle{ErrorModule::HID,
3102};
// 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};
static Core::Frontend::ControllerParameters ConvertToFrontendParameters(
ControllerSupportArgPrivate private_arg, ControllerSupportArgHeader header, bool enable_text,

View File

@@ -7,12 +7,13 @@
#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_} {}
@@ -62,8 +63,8 @@ void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
output.result = 0;
output.uuid_selected = *uuid;
} else {
status = Account::ResultCancelledByUser;
output.result = Account::ResultCancelledByUser.raw;
status = ERR_USER_CANCELLED_SELECTION;
output.result = ERR_USER_CANCELLED_SELECTION.raw;
output.uuid_selected = Common::InvalidUUID;
}

View File

@@ -170,7 +170,7 @@ private:
if (impl->GetSystem().GetExecutionMode() == AudioCore::ExecutionMode::Manual) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(Audio::ResultNotSupported);
rb.Push(ERR_NOT_SUPPORTED);
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(Audio::ResultOutOfSessions);
rb.Push(ERR_MAXIMUM_SESSIONS_REACHED);
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(Audio::ResultOutOfSessions);
rb.Push(ERR_MAXIMUM_SESSIONS_REACHED);
return;
}

View File

@@ -7,17 +7,17 @@
namespace Service::Audio {
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};
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};
} // namespace Service::Audio

View File

@@ -0,0 +1,11 @@
// 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};
}

View File

@@ -6,7 +6,7 @@
#include "common/uuid.h"
#include "core/core.h"
#include "core/hle/kernel/k_event.h"
#include "core/hle/service/acc/errors.h"
#include "core/hle/service/friend/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(Account::ResultNoNotifications);
rb.Push(ERR_NO_NOTIFICATIONS);
return;
}

View File

@@ -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(Glue::ResultProcessIdNotRegistered);
rb.Push(ERR_NOT_REGISTERED);
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(Glue::ResultProcessIdNotRegistered);
rb.Push(ERR_NOT_REGISTERED);
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(Glue::ResultInvalidProcessId);
rb.Push(ERR_INVALID_PROCESS_ID);
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(Glue::ResultAlreadyBound);
rb.Push(ERR_INVALID_ACCESS);
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(Glue::ResultAlreadyBound);
rb.Push(ERR_INVALID_ACCESS);
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(Glue::ResultAlreadyBound);
rb.Push(ERR_INVALID_ACCESS);
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 Glue::ResultProcessIdNotRegistered;
return ERR_NOT_REGISTERED;
}
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(Glue::ResultInvalidProcessId);
rb.Push(ERR_INVALID_PROCESS_ID);
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(Glue::ResultProcessIdNotRegistered);
rb.Push(ERR_NOT_REGISTERED);
return;
}

View File

@@ -7,8 +7,9 @@
namespace Service::Glue {
constexpr Result ResultInvalidProcessId{ErrorModule::ARP, 31};
constexpr Result ResultAlreadyBound{ErrorModule::ARP, 42};
constexpr Result ResultProcessIdNotRegistered{ErrorModule::ARP, 102};
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};
} // namespace Service::Glue

View File

@@ -17,12 +17,12 @@ ARPManager::~ARPManager() = default;
ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const {
if (title_id == 0) {
return Glue::ResultInvalidProcessId;
return ERR_INVALID_PROCESS_ID;
}
const auto iter = entries.find(title_id);
if (iter == entries.end()) {
return Glue::ResultProcessIdNotRegistered;
return ERR_NOT_REGISTERED;
}
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 Glue::ResultInvalidProcessId;
return ERR_INVALID_PROCESS_ID;
}
const auto iter = entries.find(title_id);
if (iter == entries.end()) {
return Glue::ResultProcessIdNotRegistered;
return ERR_NOT_REGISTERED;
}
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 Glue::ResultInvalidProcessId;
return ERR_INVALID_PROCESS_ID;
}
const auto iter = entries.find(title_id);
if (iter != entries.end()) {
return Glue::ResultAlreadyBound;
return ERR_INVALID_ACCESS;
}
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 Glue::ResultInvalidProcessId;
return ERR_INVALID_PROCESS_ID;
}
const auto iter = entries.find(title_id);
if (iter == entries.end()) {
return Glue::ResultProcessIdNotRegistered;
return ERR_NOT_REGISTERED;
}
entries.erase(iter);

View File

@@ -30,23 +30,23 @@ public:
~ARPManager();
// Returns the ApplicationLaunchProperty corresponding to the provided title ID if it was
// previously registered, otherwise ResultProcessIdNotRegistered if it was never registered or
// ResultInvalidProcessId if the title ID is 0.
// previously registered, otherwise ERR_NOT_REGISTERED if it was never registered or
// ERR_INVALID_PROCESS_ID 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 ResultProcessIdNotRegistered
// if it was never registered or ResultInvalidProcessId if the title ID is 0.
// 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.
ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const;
// Adds a new entry to the internal database with the provided parameters, returning
// ResultProcessIdNotRegistered if attempting to re-register a title ID without an intermediate
// Unregister step, and ResultInvalidProcessId if the title ID is 0.
// 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.
Result Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
// Removes the registration for the provided title ID from the database, returning
// ResultProcessIdNotRegistered if it doesn't exist in the database and ResultInvalidProcessId
// if the title ID is 0.
// ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID 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

View File

@@ -19,7 +19,7 @@
namespace IPC {
constexpr Result ResultSessionClosed{ErrorModule::HIPC, 301};
constexpr Result ERR_REMOTE_PROCESS_DEAD{ErrorModule::HIPC, 301};
class RequestHelperBase {
protected:

View File

@@ -7,6 +7,5 @@
namespace Service::NS {
constexpr Result ResultApplicationLanguageNotFound{ErrorModule::NS, 300};
}
constexpr Result ERR_APPLICATION_LANGUAGE_NOT_FOUND{ErrorModule::NS, 300};
}

View File

@@ -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 Service::NS::ResultApplicationLanguageNotFound;
return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
}
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 Service::NS::ResultApplicationLanguageNotFound;
return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
}
// 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 Service::NS::ResultApplicationLanguageNotFound;
return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
}
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 Service::NS::ResultApplicationLanguageNotFound;
return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
}
return static_cast<u64>(*language_code);

View File

@@ -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::ResultSessionClosed) {
if (rc == Kernel::ResultSessionClosed || service_rc == IPC::ERR_REMOTE_PROCESS_DEAD) {
// Close the session.
request.session->Close();

View File

@@ -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::ResultSessionClosed;
result = IPC::ERR_REMOTE_PROCESS_DEAD;
break;
}
case IPC::CommandType::ControlWithContext:

View File

@@ -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 ResultInvalidLanguage{ErrorModule::Settings, 625};
constexpr Result ERR_INVALID_LANGUAGE{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(Set::ResultInvalidLanguage);
rb.Push(ERR_INVALID_LANGUAGE);
return;
}

View File

@@ -18,10 +18,10 @@
namespace Service::SM {
constexpr Result ResultInvalidClient(ErrorModule::SM, 2);
constexpr Result ResultAlreadyRegistered(ErrorModule::SM, 4);
constexpr Result ResultInvalidServiceName(ErrorModule::SM, 6);
constexpr Result ResultNotRegistered(ErrorModule::SM, 7);
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);
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 Service::SM::ResultInvalidServiceName;
return ERR_INVALID_NAME;
}
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 Service::SM::ResultAlreadyRegistered;
return ERR_ALREADY_REGISTERED;
}
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 Service::SM::ResultNotRegistered;
return ERR_SERVICE_NOT_REGISTERED;
}
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 Service::SM::ResultNotRegistered;
return ERR_SERVICE_NOT_REGISTERED;
}
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 Service::SM::ResultInvalidClient;
return ERR_NOT_INITIALIZED;
}
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() == Service::SM::ResultInvalidServiceName) {
if (port_result.Code() == ERR_INVALID_NAME) {
LOG_ERROR(Service_SM, "Invalid service name '{}'", name);
return Service::SM::ResultInvalidServiceName;
return ERR_INVALID_NAME;
}
if (port_result.Failed()) {
LOG_INFO(Service_SM, "Waiting for service {} to become available", name);
ctx.SetIsDeferred();
return Service::SM::ResultNotRegistered;
return ERR_SERVICE_NOT_REGISTERED;
}
auto& port = port_result.Unwrap();

View File

@@ -3,7 +3,6 @@
#include <thread>
#include <fmt/format.h>
#include <math.h>
#include "common/param_package.h"
#include "common/settings.h"
@@ -12,9 +11,8 @@
namespace InputCommon {
constexpr int update_time = 10;
constexpr float default_stick_sensitivity = 0.0044f;
constexpr float default_motion_sensitivity = 0.0003f;
constexpr float maximum_rotation_speed = 2.0f;
constexpr float default_stick_sensitivity = 0.022f;
constexpr float default_motion_sensitivity = 0.008f;
constexpr int mouse_axis_x = 0;
constexpr int mouse_axis_y = 1;
constexpr int wheel_axis_x = 2;
@@ -101,13 +99,11 @@ void Mouse::UpdateMotionInput() {
const float sensitivity =
Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity;
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;
// Slow movement by 7%
if (Settings::values.mouse_panning) {
last_motion_change *= 0.93f;
} else {
last_motion_change.z *= 0.93f;
}
const BasicMotion motion_data{
@@ -120,12 +116,6 @@ 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);
}
@@ -135,7 +125,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>();
last_motion_change += {-mouse_change.y, -mouse_change.x, last_motion_change.z};
Common::Vec3<float> motion_change{-mouse_change.y, -mouse_change.x, last_motion_change.z};
const auto move_distance = mouse_change.Length();
if (move_distance == 0) {
@@ -151,6 +141,7 @@ 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();

View File

@@ -146,7 +146,6 @@ 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;
}

View File

@@ -35,7 +35,6 @@ struct Bias {
u32 index;
u32 offset_begin;
u32 offset_end;
u32 alignment;
};
using boost::container::flat_set;
@@ -350,8 +349,7 @@ std::optional<StorageBufferAddr> Track(const IR::Value& value, const Bias* bias)
.index = index.U32(),
.offset = offset.U32(),
};
const u32 alignment{bias ? bias->alignment : 8U};
if (!Common::IsAligned(storage_buffer.offset, alignment)) {
if (!Common::IsAligned(storage_buffer.offset, 16)) {
// The SSBO pointer has to be aligned
return std::nullopt;
}
@@ -373,7 +371,6 @@ 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)};
@@ -389,11 +386,8 @@ 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)) {

View File

@@ -383,8 +383,7 @@ private:
void NotifyBufferDeletion();
[[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
bool is_written = false) const;
[[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, bool is_written = false) const;
[[nodiscard]] TextureBufferBinding GetTextureBufferBinding(GPUVAddr gpu_addr, u32 size,
PixelFormat format);
@@ -803,7 +802,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, cbuf_index, is_written);
storage_buffers[stage][ssbo_index] = StorageBufferBinding(ssbo_addr, is_written);
}
template <class P>
@@ -843,7 +842,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, cbuf_index, is_written);
compute_storage_buffers[ssbo_index] = StorageBufferBinding(ssbo_addr, is_written);
}
template <class P>
@@ -1989,26 +1988,11 @@ 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 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 u32 size = gpu_memory->Read<u32>(ssbo_addr + 8);
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);

View File

@@ -164,7 +164,6 @@ void DrawManager::DrawEnd(u32 instance_count, bool force_draw) {
draw_state.index_buffer.count =
static_cast<u32>(draw_state.inline_index_draw_indexes.size() / 4);
draw_state.index_buffer.format = Maxwell3D::Regs::IndexFormat::UnsignedInt;
maxwell3d->dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
ProcessDraw(true, instance_count);
draw_state.inline_index_draw_indexes.clear();
break;

View File

@@ -22,7 +22,7 @@ BlitImageHelper::~BlitImageHelper() = default;
void BlitImageHelper::BlitColor(GLuint dst_framebuffer, GLuint src_image_view, GLuint src_sampler,
const Region2D& dst_region, const Region2D& src_region,
const Extent3D& src_size) {
glDisable(GL_CULL_FACE);
glEnable(GL_CULL_FACE);
glDisable(GL_COLOR_LOGIC_OP);
glDisable(GL_DEPTH_TEST);
glDisable(GL_STENCIL_TEST);
@@ -31,6 +31,7 @@ void BlitImageHelper::BlitColor(GLuint dst_framebuffer, GLuint src_image_view, G
glDisable(GL_ALPHA_TEST);
glDisablei(GL_BLEND, 0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glCullFace(GL_BACK);
glFrontFace(GL_CW);
glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthRangeIndexed(0, 0.0, 0.0);

View File

@@ -357,7 +357,6 @@ void RasterizerOpenGL::DrawTexture() {
.y = static_cast<s32>(draw_texture_state.src_y1)}};
blit_image.BlitColor(texture_cache.GetFramebuffer()->Handle(), texture.DefaultHandle(),
sampler->Handle(), dst_region, src_region, texture.size);
state_tracker.InvalidateState();
}
++num_queued_commands;

View File

@@ -112,17 +112,13 @@ GLenum ImageTarget(Shader::TextureType type, int num_samples = 1) {
return GL_NONE;
}
GLenum TextureMode(PixelFormat format, std::array<SwizzleSource, 4> swizzle) {
bool any_r =
std::ranges::any_of(swizzle, [](SwizzleSource s) { return s == SwizzleSource::R; });
GLenum TextureMode(PixelFormat format, bool is_first) {
switch (format) {
case PixelFormat::D24_UNORM_S8_UINT:
case PixelFormat::D32_FLOAT_S8_UINT:
// R = depth, G = stencil
return any_r ? GL_DEPTH_COMPONENT : GL_STENCIL_INDEX;
return is_first ? GL_DEPTH_COMPONENT : GL_STENCIL_INDEX;
case PixelFormat::S8_UINT_D24_UNORM:
// R = stencil, G = depth
return any_r ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;
return is_first ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;
default:
ASSERT(false);
return GL_DEPTH_COMPONENT;
@@ -212,7 +208,8 @@ 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));
glTextureParameteri(handle, GL_DEPTH_STENCIL_TEXTURE_MODE,
TextureMode(format, swizzle[0] == SwizzleSource::R));
std::ranges::transform(swizzle, swizzle.begin(), ConvertGreenRed);
break;
case PixelFormat::A5B5G5R1_UNORM: {

View File

@@ -238,7 +238,7 @@ private:
return indices;
}
void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) override {
void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) {
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) override {
void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) {
switch (index_type) {
case VK_INDEX_TYPE_UINT8_EXT:
std::memcpy(staging_data, MakeIndices<u8>(quad, first).data(), quad_size);

View File

@@ -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 = enabled](vk::CommandBuffer cmdbuf) {
scheduler.Record([enable = regs.depth_bounds_enable](vk::CommandBuffer cmdbuf) {
cmdbuf.SetDepthBoundsTestEnableEXT(enable);
});
}

View File

@@ -189,16 +189,13 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
if (info.IsRenderTarget()) {
return ImageAspectMask(info.format);
}
bool any_r =
std::ranges::any_of(info.Swizzle(), [](SwizzleSource s) { return s == SwizzleSource::R; });
const bool is_first = info.Swizzle()[0] == SwizzleSource::R;
switch (info.format) {
case PixelFormat::D24_UNORM_S8_UINT:
case PixelFormat::D32_FLOAT_S8_UINT:
// R = depth, G = stencil
return any_r ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT;
return is_first ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT;
case PixelFormat::S8_UINT_D24_UNORM:
// R = stencil, G = depth
return any_r ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
return is_first ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
case PixelFormat::D16_UNORM:
case PixelFormat::D32_FLOAT:
return VK_IMAGE_ASPECT_DEPTH_BIT;
@@ -1772,7 +1769,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_FLOAT_CUSTOM_EXT : ConvertBorderColor(color),
arbitrary_borders ? VK_BORDER_COLOR_INT_CUSTOM_EXT : ConvertBorderColor(color),
.unnormalizedCoordinates = VK_FALSE,
});
}