Fixed an issue with reserved memory, updated strings and reworked LogicOp fix

This commit is contained in:
Jarrod Norwell 2024-05-31 13:52:45 +08:00
parent 786d8e2618
commit 5ee0744893
18 changed files with 93 additions and 43 deletions

View File

@ -82,7 +82,7 @@ struct UUID {
*/ */
static constexpr UUID MakeDefault() { static constexpr UUID MakeDefault() {
return UUID{ return UUID{
{'y', 'u', 'z', 'u', ' ', 'D', 'e', 'f', 'a', 'u', 'l', 't', ' ', 'U', 'I', 'D'}, {'s', 'u', 'd', 'a', ' ', 'D', 'e', 'f', 'a', 'u', 'l', 't', ' ', 'U', 'I', 'D'},
}; };
} }

View File

@ -259,9 +259,9 @@ Result KPageTableBase::InitializeForProcess(Svc::CreateProcessFlag as_type, bool
// [switchbrew.org][0] Address space type must be 39-bit // [switchbrew.org][0] Address space type must be 39-bit
// [switchbrew.org][1] System resource size must be > 0 // [switchbrew.org][1] System resource size must be > 0
// [switchbrew.org][2] KTargetSystem::IsDebugMode() must be true // [switchbrew.org][2] KTargetSystem::IsDebugMode() must be true
if (as_type == Svc::CreateProcessFlag::EnableReservedRegionExtraSize) { if ((as_type & Svc::CreateProcessFlag::AddressSpaceMask) ==
m_reserved_region_extra_size = GetAddressSpaceSize() / 8; Svc::CreateProcessFlag::EnableReservedRegionExtraSize) {
alias_region_size += alias_region_size; m_reserved_region_extra_size += GetAddressSpaceSize() / 8;
} }
} else { } else {
stack_region_size = 0; stack_region_size = 0;

View File

@ -656,7 +656,7 @@ public:
void* native_context{}; void* native_context{};
std::atomic<u32> lock{1}; std::atomic<u32> lock{1};
bool is_running{}; bool is_running{};
u32 magic{Common::MakeMagic('Y', 'U', 'Z', 'U')}; u32 magic{Common::MakeMagic('S', 'U', 'D', 'A')};
}; };
NativeExecutionParameters& GetNativeExecutionParameters() { NativeExecutionParameters& GetNativeExecutionParameters() {

View File

@ -17,9 +17,8 @@ namespace Service::AM::Applets {
Cabinet::Cabinet(Core::System& system_, LibraryAppletMode applet_mode_, Cabinet::Cabinet(Core::System& system_, LibraryAppletMode applet_mode_,
const Core::Frontend::CabinetApplet& frontend_) const Core::Frontend::CabinetApplet& frontend_)
: Applet{system_, applet_mode_}, frontend{frontend_}, system{system_}, service_context{ : Applet{system_, applet_mode_}, frontend{frontend_}, system{system_},
system_, service_context{system_, "CabinetApplet"} {
"CabinetApplet"} {
availability_change_event = availability_change_event =
service_context.CreateEvent("CabinetApplet:AvailabilityChangeEvent"); service_context.CreateEvent("CabinetApplet:AvailabilityChangeEvent");
@ -123,7 +122,7 @@ void Cabinet::DisplayCompleted(bool apply_changes, std::string_view amiibo_name)
std::memcpy(register_info.amiibo_name.data(), amiibo_name.data(), std::memcpy(register_info.amiibo_name.data(), amiibo_name.data(),
std::min(amiibo_name.size(), register_info.amiibo_name.size() - 1)); std::min(amiibo_name.size(), register_info.amiibo_name.size() - 1));
register_info.mii_store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All); register_info.mii_store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All);
register_info.mii_store_data.SetNickname({u'y', u'u', u'z', u'u'}); register_info.mii_store_data.SetNickname({u's', u'u', u'd', u'a'});
nfp_device->SetRegisterInfoPrivate(register_info); nfp_device->SetRegisterInfoPrivate(register_info);
break; break;
} }

View File

@ -93,7 +93,7 @@ void MiiEdit::Execute() {
case MiiEditAppletMode::AppendMii: { case MiiEditAppletMode::AppendMii: {
Mii::StoreData store_data{}; Mii::StoreData store_data{};
store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All); store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All);
store_data.SetNickname({u'y', u'u', u'z', u'u'}); store_data.SetNickname({u's', u'u', u'd', u'a'});
store_data.SetChecksum(); store_data.SetChecksum();
const auto result = manager->AddOrReplace(metadata, store_data); const auto result = manager->AddOrReplace(metadata, store_data);

View File

@ -48,8 +48,8 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
{59, nullptr, "SetVrPositionForDebug"}, {59, nullptr, "SetVrPositionForDebug"},
{60, &ICommonStateGetter::GetDefaultDisplayResolution, "GetDefaultDisplayResolution"}, {60, &ICommonStateGetter::GetDefaultDisplayResolution, "GetDefaultDisplayResolution"},
{61, &ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent, "GetDefaultDisplayResolutionChangeEvent"}, {61, &ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent, "GetDefaultDisplayResolutionChangeEvent"},
{62, nullptr, "GetHdcpAuthenticationState"}, {62, &ICommonStateGetter::GetHdcpAuthenticationState, "GetHdcpAuthenticationState"},
{63, nullptr, "GetHdcpAuthenticationStateChangeEvent"}, {63, &ICommonStateGetter::GetHdcpAuthenticationStateChangeEvent, "GetHdcpAuthenticationStateChangeEvent"},
{64, nullptr, "SetTvPowerStateMatchingMode"}, {64, nullptr, "SetTvPowerStateMatchingMode"},
{65, nullptr, "GetApplicationIdByContentActionName"}, {65, nullptr, "GetApplicationIdByContentActionName"},
{66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"}, {66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"},
@ -252,6 +252,15 @@ void ICommonStateGetter::GetDefaultDisplayResolution(HLERequestContext& ctx) {
} }
} }
void ICommonStateGetter::GetHdcpAuthenticationState(HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void ICommonStateGetter::GetHdcpAuthenticationStateChangeEvent(HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void ICommonStateGetter::SetCpuBoostMode(HLERequestContext& ctx) { void ICommonStateGetter::SetCpuBoostMode(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called, forwarding to APM:SYS"); LOG_DEBUG(Service_AM, "called, forwarding to APM:SYS");

View File

@ -55,6 +55,8 @@ private:
void GetAcquiredSleepLockEvent(HLERequestContext& ctx); void GetAcquiredSleepLockEvent(HLERequestContext& ctx);
void GetReaderLockAccessorEx(HLERequestContext& ctx); void GetReaderLockAccessorEx(HLERequestContext& ctx);
void GetDefaultDisplayResolutionChangeEvent(HLERequestContext& ctx); void GetDefaultDisplayResolutionChangeEvent(HLERequestContext& ctx);
void GetHdcpAuthenticationState(HLERequestContext& ctx);
void GetHdcpAuthenticationStateChangeEvent(HLERequestContext& ctx);
void GetOperationMode(HLERequestContext& ctx); void GetOperationMode(HLERequestContext& ctx);
void GetPerformanceMode(HLERequestContext& ctx); void GetPerformanceMode(HLERequestContext& ctx);
void GetBootMode(HLERequestContext& ctx); void GetBootMode(HLERequestContext& ctx);

View File

@ -18,9 +18,8 @@ namespace Service::AM::Frontend {
Cabinet::Cabinet(Core::System& system_, std::shared_ptr<Applet> applet_, Cabinet::Cabinet(Core::System& system_, std::shared_ptr<Applet> applet_,
LibraryAppletMode applet_mode_, const Core::Frontend::CabinetApplet& frontend_) LibraryAppletMode applet_mode_, const Core::Frontend::CabinetApplet& frontend_)
: FrontendApplet{system_, applet_, applet_mode_}, frontend{frontend_}, service_context{ : FrontendApplet{system_, applet_, applet_mode_}, frontend{frontend_},
system_, service_context{system_, "CabinetApplet"} {
"CabinetApplet"} {
availability_change_event = availability_change_event =
service_context.CreateEvent("CabinetApplet:AvailabilityChangeEvent"); service_context.CreateEvent("CabinetApplet:AvailabilityChangeEvent");
@ -120,7 +119,7 @@ void Cabinet::DisplayCompleted(bool apply_changes, std::string_view amiibo_name)
std::memcpy(register_info.amiibo_name.data(), amiibo_name.data(), std::memcpy(register_info.amiibo_name.data(), amiibo_name.data(),
std::min(amiibo_name.size(), register_info.amiibo_name.size() - 1)); std::min(amiibo_name.size(), register_info.amiibo_name.size() - 1));
register_info.mii_store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All); register_info.mii_store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All);
register_info.mii_store_data.SetNickname({u'y', u'u', u'z', u'u'}); register_info.mii_store_data.SetNickname({u's', u'u', u'd', u'a'});
nfp_device->SetRegisterInfoPrivate(register_info); nfp_device->SetRegisterInfoPrivate(register_info);
break; break;
} }

View File

@ -90,7 +90,7 @@ void MiiEdit::Execute() {
case MiiEditAppletMode::AppendMii: { case MiiEditAppletMode::AppendMii: {
Mii::StoreData store_data{}; Mii::StoreData store_data{};
store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All); store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All);
store_data.SetNickname({u'y', u'u', u'z', u'u'}); store_data.SetNickname({u's', u'u', u'd', u'a'});
store_data.SetChecksum(); store_data.SetChecksum();
const auto result = manager->AddOrReplace(metadata, store_data); const auto result = manager->AddOrReplace(metadata, store_data);

View File

@ -9,7 +9,7 @@ namespace Service::AM {
LifecycleManager::LifecycleManager(Core::System& system, KernelHelpers::ServiceContext& context, LifecycleManager::LifecycleManager(Core::System& system, KernelHelpers::ServiceContext& context,
bool is_application) bool is_application)
: m_system_event(context), m_operation_mode_changed_system_event(context), : m_system_event(context), m_operation_mode_changed_system_event(context),
m_is_application(is_application) {} m_hdcp_state_changed_event(context), m_is_application(is_application) {}
LifecycleManager::~LifecycleManager() = default; LifecycleManager::~LifecycleManager() = default;
@ -21,6 +21,10 @@ Event& LifecycleManager::GetOperationModeChangedSystemEvent() {
return m_operation_mode_changed_system_event; return m_operation_mode_changed_system_event;
} }
Event& LifecycleManager::GetHDCPStateChangedEvent() {
return m_hdcp_state_changed_event;
}
void LifecycleManager::PushUnorderedMessage(AppletMessage message) { void LifecycleManager::PushUnorderedMessage(AppletMessage message) {
m_unordered_messages.push_back(message); m_unordered_messages.push_back(message);
this->SignalSystemEventIfNeeded(); this->SignalSystemEventIfNeeded();

View File

@ -42,6 +42,7 @@ public:
public: public:
Event& GetSystemEvent(); Event& GetSystemEvent();
Event& GetOperationModeChangedSystemEvent(); Event& GetOperationModeChangedSystemEvent();
Event& GetHDCPStateChangedEvent();
public: public:
bool IsApplication() { bool IsApplication() {
@ -145,12 +146,14 @@ private:
private: private:
Event m_system_event; Event m_system_event;
Event m_operation_mode_changed_system_event; Event m_operation_mode_changed_system_event;
Event m_hdcp_state_changed_event;
std::list<AppletMessage> m_unordered_messages{}; std::list<AppletMessage> m_unordered_messages{};
bool m_is_application{}; bool m_is_application{};
bool m_focus_state_changed_notification_enabled{true}; bool m_focus_state_changed_notification_enabled{true};
bool m_operation_mode_changed_notification_enabled{true}; bool m_operation_mode_changed_notification_enabled{true};
bool m_hdcp_state_changed_notification_enabled{true};
bool m_performance_mode_changed_notification_enabled{true}; bool m_performance_mode_changed_notification_enabled{true};
bool m_resume_notification_enabled{}; bool m_resume_notification_enabled{};

View File

@ -48,8 +48,8 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
{59, nullptr, "SetVrPositionForDebug"}, {59, nullptr, "SetVrPositionForDebug"},
{60, D<&ICommonStateGetter::GetDefaultDisplayResolution>, "GetDefaultDisplayResolution"}, {60, D<&ICommonStateGetter::GetDefaultDisplayResolution>, "GetDefaultDisplayResolution"},
{61, D<&ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent>, "GetDefaultDisplayResolutionChangeEvent"}, {61, D<&ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent>, "GetDefaultDisplayResolutionChangeEvent"},
{62, nullptr, "GetHdcpAuthenticationState"}, {62, D<&ICommonStateGetter::GetHdcpAuthenticationState>, "GetHdcpAuthenticationState"},
{63, nullptr, "GetHdcpAuthenticationStateChangeEvent"}, {63, D<&ICommonStateGetter::GetHdcpAuthenticationStateChangeEvent>, "GetHdcpAuthenticationStateChangeEvent"},
{64, nullptr, "SetTvPowerStateMatchingMode"}, {64, nullptr, "SetTvPowerStateMatchingMode"},
{65, nullptr, "GetApplicationIdByContentActionName"}, {65, nullptr, "GetApplicationIdByContentActionName"},
{66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"}, {66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"},
@ -142,6 +142,19 @@ Result ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(
R_SUCCEED(); R_SUCCEED();
} }
Result ICommonStateGetter::GetHdcpAuthenticationState(Out<s32> out_state) {
LOG_DEBUG(Service_AM, "called");
*out_state = 1;
R_SUCCEED();
}
Result ICommonStateGetter::GetHdcpAuthenticationStateChangeEvent(
OutCopyHandle<Kernel::KReadableEvent> out_event) {
LOG_DEBUG(Service_AM, "called");
*out_event = m_applet->lifecycle_manager.GetHDCPStateChangedEvent().GetHandle();
R_SUCCEED();
}
Result ICommonStateGetter::GetOperationMode(Out<OperationMode> out_operation_mode) { Result ICommonStateGetter::GetOperationMode(Out<OperationMode> out_operation_mode) {
const bool use_docked_mode{Settings::IsDockedMode()}; const bool use_docked_mode{Settings::IsDockedMode()};
LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode); LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode);

View File

@ -35,6 +35,8 @@ private:
Result GetWriterLockAccessorEx(Out<SharedPointer<ILockAccessor>> out_lock_accessor, Result GetWriterLockAccessorEx(Out<SharedPointer<ILockAccessor>> out_lock_accessor,
u32 button_type); u32 button_type);
Result GetDefaultDisplayResolutionChangeEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); Result GetDefaultDisplayResolutionChangeEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result GetHdcpAuthenticationState(Out<s32> out_state);
Result GetHdcpAuthenticationStateChangeEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result GetOperationMode(Out<OperationMode> out_operation_mode); Result GetOperationMode(Out<OperationMode> out_operation_mode);
Result GetPerformanceMode(Out<APM::PerformanceMode> out_performance_mode); Result GetPerformanceMode(Out<APM::PerformanceMode> out_performance_mode);
Result GetBootMode(Out<PM::SystemBootMode> out_boot_mode); Result GetBootMode(Out<PM::SystemBootMode> out_boot_mode);

View File

@ -628,7 +628,7 @@ Result NfcDevice::Restore() {
LOG_ERROR(Service_NFP, "Regenerating mii data"); LOG_ERROR(Service_NFP, "Regenerating mii data");
Mii::StoreData new_mii{}; Mii::StoreData new_mii{};
new_mii.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All); new_mii.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All);
new_mii.SetNickname({u'y', u'u', u'z', u'u', u'\0'}); new_mii.SetNickname({u's', u'u', u'd', u'a', u'\0'});
tag_data.owner_mii.BuildFromStoreData(new_mii); tag_data.owner_mii.BuildFromStoreData(new_mii);
tag_data.mii_extension.SetFromStoreData(new_mii); tag_data.mii_extension.SetFromStoreData(new_mii);
@ -1494,7 +1494,7 @@ void NfcDevice::BuildAmiiboWithoutKeys(NFP::NTAG215File& stubbed_tag_data,
settings.write_date = GetAmiiboDate(GetCurrentPosixTime()); settings.write_date = GetAmiiboDate(GetCurrentPosixTime());
// Register info // Register info
SetAmiiboName(settings, {'y', 'u', 'z', 'u', 'A', 'm', 'i', 'i', 'b', 'o'}); SetAmiiboName(settings, {'s', 'u', 'd', 'a', 'A', 'm', 'i', 'i', 'b', 'o'});
settings.settings.font_region.Assign(0); settings.settings.font_region.Assign(0);
settings.init_date = GetAmiiboDate(GetCurrentPosixTime()); settings.init_date = GetAmiiboDate(GetCurrentPosixTime());
store_data.BuildBase(Mii::Gender::Male); store_data.BuildBase(Mii::Gender::Male);

View File

@ -26,7 +26,7 @@ namespace Service::Set {
namespace { namespace {
constexpr u32 SETTINGS_VERSION{1u}; constexpr u32 SETTINGS_VERSION{1u};
constexpr auto SETTINGS_MAGIC = Common::MakeMagic('y', 'u', 'z', 'u', '_', 's', 'e', 't'); constexpr auto SETTINGS_MAGIC = Common::MakeMagic('s', 'u', 'd', 'a', '_', 's', 'e', 't');
struct SettingsHeader { struct SettingsHeader {
u64 magic; u64 magic;
u32 version; u32 version;

View File

@ -1208,17 +1208,24 @@ void RasterizerOpenGL::SyncLogicOpState() {
} }
flags[Dirty::LogicOp] = false; flags[Dirty::LogicOp] = false;
const auto& regs = maxwell3d->regs; auto& regs = maxwell3d->regs;
bool has_float = false; if (device.IsAmd()) {
struct In {
const Tegra::Engines::Maxwell3D::Regs::VertexAttribute::Type d;
In(Tegra::Engines::Maxwell3D::Regs::VertexAttribute::Type n) : d(n) {}
bool operator()(Tegra::Engines::Maxwell3D::Regs::VertexAttribute n) const {
return n.type == d;
}
};
if (std::any_of(regs.vertex_attrib_format.begin(), regs.vertex_attrib_format.end(), bool has_float =
[&](Tegra::Engines::Maxwell3D::Regs::VertexAttribute attribute) { std::any_of(regs.vertex_attrib_format.begin(), regs.vertex_attrib_format.end(),
return IsAnyFloat(attribute); In(Tegra::Engines::Maxwell3D::Regs::VertexAttribute::Type::Float));
})) regs.logic_op.enable = static_cast<u32>(!has_float);
has_float = true; }
if (regs.logic_op.enable && !has_float) { if (regs.logic_op.enable) {
glEnable(GL_COLOR_LOGIC_OP); glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(MaxwellToGL::LogicOp(regs.logic_op.op)); glLogicOp(MaxwellToGL::LogicOp(regs.logic_op.op));
} else { } else {

View File

@ -54,7 +54,7 @@ using VideoCommon::GenericEnvironment;
using VideoCommon::GraphicsEnvironment; using VideoCommon::GraphicsEnvironment;
constexpr u32 CACHE_VERSION = 11; constexpr u32 CACHE_VERSION = 11;
constexpr std::array<char, 8> VULKAN_CACHE_MAGIC_NUMBER{'y', 'u', 'z', 'u', 'v', 'k', 'c', 'h'}; constexpr std::array<char, 8> VULKAN_CACHE_MAGIC_NUMBER{'s', 'u', 'd', 'a', 'v', 'k', 'c', 'h'};
template <typename Container> template <typename Container>
auto MakeSpan(Container& container) { auto MakeSpan(Container& container) {

View File

@ -952,7 +952,27 @@ void RasterizerVulkan::UpdateDynamicStates() {
UpdateDepthBiasEnable(regs); UpdateDepthBiasEnable(regs);
} }
if (device.IsExtExtendedDynamicState3EnablesSupported()) { if (device.IsExtExtendedDynamicState3EnablesSupported()) {
UpdateLogicOpEnable(regs); const auto old = regs.logic_op.enable;
if (device.GetDriverID() == VkDriverIdKHR::VK_DRIVER_ID_AMD_OPEN_SOURCE ||
device.GetDriverID() == VkDriverIdKHR::VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR) {
struct In {
const Tegra::Engines::Maxwell3D::Regs::VertexAttribute::Type d;
In(Tegra::Engines::Maxwell3D::Regs::VertexAttribute::Type n) : d(n) {}
bool operator()(Tegra::Engines::Maxwell3D::Regs::VertexAttribute n) const {
return n.type == d;
}
};
auto has_float = std::any_of(
regs.vertex_attrib_format.begin(), regs.vertex_attrib_format.end(),
In(Tegra::Engines::Maxwell3D::Regs::VertexAttribute::Type::Float));
regs.logic_op.enable = static_cast<u32>(!has_float);
UpdateLogicOpEnable(regs);
regs.logic_op.enable = old;
} else
UpdateLogicOpEnable(regs);
UpdateDepthClampEnable(regs); UpdateDepthClampEnable(regs);
} }
} }
@ -1319,16 +1339,8 @@ void RasterizerVulkan::UpdateLogicOpEnable(Tegra::Engines::Maxwell3D::Regs& regs
return; return;
} }
scheduler.Record([&, regs](vk::CommandBuffer cmdbuf) { scheduler.Record([&, enable = regs.logic_op.enable](vk::CommandBuffer cmdbuf) {
bool has_float = false; cmdbuf.SetLogicOpEnableEXT(enable != 0);
if (std::any_of(regs.vertex_attrib_format.begin(), regs.vertex_attrib_format.end(),
[&](Tegra::Engines::Maxwell3D::Regs::VertexAttribute attribute) {
return IsAnyFloat(attribute);
}))
has_float = true;
cmdbuf.SetLogicOpEnableEXT((regs.logic_op.enable != 0 && !has_float) ? true : false);
}); });
} }