diff options
23 files changed, 275 insertions, 50 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index c7c579aaf..7e8e87c33 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -395,16 +395,42 @@ struct BreakReason { | |||
| 395 | /// Break program execution | 395 | /// Break program execution |
| 396 | static void Break(u32 reason, u64 info1, u64 info2) { | 396 | static void Break(u32 reason, u64 info1, u64 info2) { |
| 397 | BreakReason break_reason{reason}; | 397 | BreakReason break_reason{reason}; |
| 398 | bool has_dumped_buffer{}; | ||
| 398 | 399 | ||
| 400 | const auto handle_debug_buffer = [&](VAddr addr, u64 sz) { | ||
| 401 | if (sz == 0 || addr == 0 || has_dumped_buffer) { | ||
| 402 | return; | ||
| 403 | } | ||
| 404 | |||
| 405 | // This typically is an error code so we're going to assume this is the case | ||
| 406 | if (sz == sizeof(u32)) { | ||
| 407 | LOG_CRITICAL(Debug_Emulated, "debug_buffer_err_code={:X}", Memory::Read32(addr)); | ||
| 408 | } else { | ||
| 409 | // We don't know what's in here so we'll hexdump it | ||
| 410 | std::vector<u8> debug_buffer(sz); | ||
| 411 | Memory::ReadBlock(addr, debug_buffer.data(), sz); | ||
| 412 | std::string hexdump; | ||
| 413 | for (std::size_t i = 0; i < debug_buffer.size(); i++) { | ||
| 414 | hexdump += fmt::format("{:02X} ", debug_buffer[i]); | ||
| 415 | if (i != 0 && i % 16 == 0) { | ||
| 416 | hexdump += '\n'; | ||
| 417 | } | ||
| 418 | } | ||
| 419 | LOG_CRITICAL(Debug_Emulated, "debug_buffer=\n{}", hexdump); | ||
| 420 | } | ||
| 421 | has_dumped_buffer = true; | ||
| 422 | }; | ||
| 399 | switch (break_reason.break_type) { | 423 | switch (break_reason.break_type) { |
| 400 | case BreakType::Panic: | 424 | case BreakType::Panic: |
| 401 | LOG_CRITICAL(Debug_Emulated, "Signalling debugger, PANIC! info1=0x{:016X}, info2=0x{:016X}", | 425 | LOG_CRITICAL(Debug_Emulated, "Signalling debugger, PANIC! info1=0x{:016X}, info2=0x{:016X}", |
| 402 | info1, info2); | 426 | info1, info2); |
| 427 | handle_debug_buffer(info1, info2); | ||
| 403 | break; | 428 | break; |
| 404 | case BreakType::AssertionFailed: | 429 | case BreakType::AssertionFailed: |
| 405 | LOG_CRITICAL(Debug_Emulated, | 430 | LOG_CRITICAL(Debug_Emulated, |
| 406 | "Signalling debugger, Assertion failed! info1=0x{:016X}, info2=0x{:016X}", | 431 | "Signalling debugger, Assertion failed! info1=0x{:016X}, info2=0x{:016X}", |
| 407 | info1, info2); | 432 | info1, info2); |
| 433 | handle_debug_buffer(info1, info2); | ||
| 408 | break; | 434 | break; |
| 409 | case BreakType::PreNROLoad: | 435 | case BreakType::PreNROLoad: |
| 410 | LOG_WARNING( | 436 | LOG_WARNING( |
| @@ -433,6 +459,7 @@ static void Break(u32 reason, u64 info1, u64 info2) { | |||
| 433 | Debug_Emulated, | 459 | Debug_Emulated, |
| 434 | "Signalling debugger, Unknown break reason {}, info1=0x{:016X}, info2=0x{:016X}", | 460 | "Signalling debugger, Unknown break reason {}, info1=0x{:016X}, info2=0x{:016X}", |
| 435 | static_cast<u32>(break_reason.break_type.Value()), info1, info2); | 461 | static_cast<u32>(break_reason.break_type.Value()), info1, info2); |
| 462 | handle_debug_buffer(info1, info2); | ||
| 436 | break; | 463 | break; |
| 437 | } | 464 | } |
| 438 | 465 | ||
| @@ -441,6 +468,7 @@ static void Break(u32 reason, u64 info1, u64 info2) { | |||
| 441 | Debug_Emulated, | 468 | Debug_Emulated, |
| 442 | "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}", | 469 | "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}", |
| 443 | reason, info1, info2); | 470 | reason, info1, info2); |
| 471 | handle_debug_buffer(info1, info2); | ||
| 444 | ASSERT(false); | 472 | ASSERT(false); |
| 445 | 473 | ||
| 446 | Core::CurrentProcess()->PrepareForTermination(); | 474 | Core::CurrentProcess()->PrepareForTermination(); |
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index c6437a671..8318eff5f 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -242,6 +242,28 @@ void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestCo | |||
| 242 | LOG_DEBUG(Service_ACC, "called"); | 242 | LOG_DEBUG(Service_ACC, "called"); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx) { | ||
| 246 | LOG_DEBUG(Service_ACC, "called"); | ||
| 247 | // A u8 is passed into this function which we can safely ignore. It's to determine if we have | ||
| 248 | // access to use the network or not by the looks of it | ||
| 249 | IPC::ResponseBuilder rb{ctx, 6}; | ||
| 250 | if (profile_manager->GetUserCount() != 1) { | ||
| 251 | rb.Push(RESULT_SUCCESS); | ||
| 252 | rb.PushRaw<u128>(INVALID_UUID); | ||
| 253 | return; | ||
| 254 | } | ||
| 255 | auto user_list = profile_manager->GetAllUsers(); | ||
| 256 | if (user_list.empty()) { | ||
| 257 | rb.Push(ResultCode(-1)); // TODO(ogniK): Find the correct error code | ||
| 258 | rb.PushRaw<u128>(INVALID_UUID); | ||
| 259 | return; | ||
| 260 | } | ||
| 261 | |||
| 262 | // Select the first user we have | ||
| 263 | rb.Push(RESULT_SUCCESS); | ||
| 264 | rb.PushRaw<u128>(profile_manager->GetUser(0)->uuid); | ||
| 265 | } | ||
| 266 | |||
| 245 | Module::Interface::Interface(std::shared_ptr<Module> module, | 267 | Module::Interface::Interface(std::shared_ptr<Module> module, |
| 246 | std::shared_ptr<ProfileManager> profile_manager, const char* name) | 268 | std::shared_ptr<ProfileManager> profile_manager, const char* name) |
| 247 | : ServiceFramework(name), module(std::move(module)), | 269 | : ServiceFramework(name), module(std::move(module)), |
diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h index c7ed74351..89b2104fa 100644 --- a/src/core/hle/service/acc/acc.h +++ b/src/core/hle/service/acc/acc.h | |||
| @@ -27,6 +27,7 @@ public: | |||
| 27 | void InitializeApplicationInfo(Kernel::HLERequestContext& ctx); | 27 | void InitializeApplicationInfo(Kernel::HLERequestContext& ctx); |
| 28 | void GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx); | 28 | void GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx); |
| 29 | void IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx); | 29 | void IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx); |
| 30 | void TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx); | ||
| 30 | 31 | ||
| 31 | protected: | 32 | protected: |
| 32 | std::shared_ptr<Module> module; | 33 | std::shared_ptr<Module> module; |
diff --git a/src/core/hle/service/acc/acc_su.cpp b/src/core/hle/service/acc/acc_su.cpp index ad455c3a7..5e2030355 100644 --- a/src/core/hle/service/acc/acc_su.cpp +++ b/src/core/hle/service/acc/acc_su.cpp | |||
| @@ -17,7 +17,7 @@ ACC_SU::ACC_SU(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> p | |||
| 17 | {5, &ACC_SU::GetProfile, "GetProfile"}, | 17 | {5, &ACC_SU::GetProfile, "GetProfile"}, |
| 18 | {6, nullptr, "GetProfileDigest"}, | 18 | {6, nullptr, "GetProfileDigest"}, |
| 19 | {50, &ACC_SU::IsUserRegistrationRequestPermitted, "IsUserRegistrationRequestPermitted"}, | 19 | {50, &ACC_SU::IsUserRegistrationRequestPermitted, "IsUserRegistrationRequestPermitted"}, |
| 20 | {51, nullptr, "TrySelectUserWithoutInteraction"}, | 20 | {51, &ACC_SU::TrySelectUserWithoutInteraction, "TrySelectUserWithoutInteraction"}, |
| 21 | {60, nullptr, "ListOpenContextStoredUsers"}, | 21 | {60, nullptr, "ListOpenContextStoredUsers"}, |
| 22 | {100, nullptr, "GetUserRegistrationNotifier"}, | 22 | {100, nullptr, "GetUserRegistrationNotifier"}, |
| 23 | {101, nullptr, "GetUserStateChangeNotifier"}, | 23 | {101, nullptr, "GetUserStateChangeNotifier"}, |
diff --git a/src/core/hle/service/acc/acc_u0.cpp b/src/core/hle/service/acc/acc_u0.cpp index 72d4adf35..a4d705b45 100644 --- a/src/core/hle/service/acc/acc_u0.cpp +++ b/src/core/hle/service/acc/acc_u0.cpp | |||
| @@ -17,7 +17,7 @@ ACC_U0::ACC_U0(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> p | |||
| 17 | {5, &ACC_U0::GetProfile, "GetProfile"}, | 17 | {5, &ACC_U0::GetProfile, "GetProfile"}, |
| 18 | {6, nullptr, "GetProfileDigest"}, | 18 | {6, nullptr, "GetProfileDigest"}, |
| 19 | {50, &ACC_U0::IsUserRegistrationRequestPermitted, "IsUserRegistrationRequestPermitted"}, | 19 | {50, &ACC_U0::IsUserRegistrationRequestPermitted, "IsUserRegistrationRequestPermitted"}, |
| 20 | {51, nullptr, "TrySelectUserWithoutInteraction"}, | 20 | {51, &ACC_U0::TrySelectUserWithoutInteraction, "TrySelectUserWithoutInteraction"}, |
| 21 | {60, nullptr, "ListOpenContextStoredUsers"}, | 21 | {60, nullptr, "ListOpenContextStoredUsers"}, |
| 22 | {100, &ACC_U0::InitializeApplicationInfo, "InitializeApplicationInfo"}, | 22 | {100, &ACC_U0::InitializeApplicationInfo, "InitializeApplicationInfo"}, |
| 23 | {101, &ACC_U0::GetBaasAccountManagerForApplication, "GetBaasAccountManagerForApplication"}, | 23 | {101, &ACC_U0::GetBaasAccountManagerForApplication, "GetBaasAccountManagerForApplication"}, |
diff --git a/src/core/hle/service/acc/acc_u1.cpp b/src/core/hle/service/acc/acc_u1.cpp index d480f08e5..8fffc93b5 100644 --- a/src/core/hle/service/acc/acc_u1.cpp +++ b/src/core/hle/service/acc/acc_u1.cpp | |||
| @@ -17,7 +17,7 @@ ACC_U1::ACC_U1(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> p | |||
| 17 | {5, &ACC_U1::GetProfile, "GetProfile"}, | 17 | {5, &ACC_U1::GetProfile, "GetProfile"}, |
| 18 | {6, nullptr, "GetProfileDigest"}, | 18 | {6, nullptr, "GetProfileDigest"}, |
| 19 | {50, &ACC_U1::IsUserRegistrationRequestPermitted, "IsUserRegistrationRequestPermitted"}, | 19 | {50, &ACC_U1::IsUserRegistrationRequestPermitted, "IsUserRegistrationRequestPermitted"}, |
| 20 | {51, nullptr, "TrySelectUserWithoutInteraction"}, | 20 | {51, &ACC_U1::TrySelectUserWithoutInteraction, "TrySelectUserWithoutInteraction"}, |
| 21 | {60, nullptr, "ListOpenContextStoredUsers"}, | 21 | {60, nullptr, "ListOpenContextStoredUsers"}, |
| 22 | {100, nullptr, "GetUserRegistrationNotifier"}, | 22 | {100, nullptr, "GetUserRegistrationNotifier"}, |
| 23 | {101, nullptr, "GetUserStateChangeNotifier"}, | 23 | {101, nullptr, "GetUserStateChangeNotifier"}, |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index ac3ff9f20..0477ce66e 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -338,7 +338,54 @@ void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& c | |||
| 338 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 338 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | ICommonStateGetter::ICommonStateGetter() : ServiceFramework("ICommonStateGetter") { | 341 | AppletMessageQueue::AppletMessageQueue() { |
| 342 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 343 | on_new_message = Kernel::Event::Create(kernel, Kernel::ResetType::Sticky, | ||
| 344 | "AMMessageQueue:OnMessageRecieved"); | ||
| 345 | on_operation_mode_changed = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, | ||
| 346 | "AMMessageQueue:OperationModeChanged"); | ||
| 347 | } | ||
| 348 | |||
| 349 | AppletMessageQueue::~AppletMessageQueue() = default; | ||
| 350 | |||
| 351 | const Kernel::SharedPtr<Kernel::Event>& AppletMessageQueue::GetMesssageRecieveEvent() const { | ||
| 352 | return on_new_message; | ||
| 353 | } | ||
| 354 | |||
| 355 | const Kernel::SharedPtr<Kernel::Event>& AppletMessageQueue::GetOperationModeChangedEvent() const { | ||
| 356 | return on_operation_mode_changed; | ||
| 357 | } | ||
| 358 | |||
| 359 | void AppletMessageQueue::PushMessage(AppletMessage msg) { | ||
| 360 | messages.push(msg); | ||
| 361 | on_new_message->Signal(); | ||
| 362 | } | ||
| 363 | |||
| 364 | AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() { | ||
| 365 | if (messages.empty()) { | ||
| 366 | on_new_message->Clear(); | ||
| 367 | return AppletMessage::NoMessage; | ||
| 368 | } | ||
| 369 | auto msg = messages.front(); | ||
| 370 | messages.pop(); | ||
| 371 | if (messages.empty()) { | ||
| 372 | on_new_message->Clear(); | ||
| 373 | } | ||
| 374 | return msg; | ||
| 375 | } | ||
| 376 | |||
| 377 | std::size_t AppletMessageQueue::GetMessageCount() const { | ||
| 378 | return messages.size(); | ||
| 379 | } | ||
| 380 | |||
| 381 | void AppletMessageQueue::OperationModeChanged() { | ||
| 382 | PushMessage(AppletMessage::OperationModeChanged); | ||
| 383 | PushMessage(AppletMessage::PerformanceModeChanged); | ||
| 384 | on_operation_mode_changed->Signal(); | ||
| 385 | } | ||
| 386 | |||
| 387 | ICommonStateGetter::ICommonStateGetter(std::shared_ptr<AppletMessageQueue> msg_queue) | ||
| 388 | : ServiceFramework("ICommonStateGetter"), msg_queue(std::move(msg_queue)) { | ||
| 342 | // clang-format off | 389 | // clang-format off |
| 343 | static const FunctionInfo functions[] = { | 390 | static const FunctionInfo functions[] = { |
| 344 | {0, &ICommonStateGetter::GetEventHandle, "GetEventHandle"}, | 391 | {0, &ICommonStateGetter::GetEventHandle, "GetEventHandle"}, |
| @@ -388,21 +435,19 @@ void ICommonStateGetter::GetBootMode(Kernel::HLERequestContext& ctx) { | |||
| 388 | } | 435 | } |
| 389 | 436 | ||
| 390 | void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) { | 437 | void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) { |
| 391 | event->Signal(); | ||
| 392 | |||
| 393 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 438 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 394 | rb.Push(RESULT_SUCCESS); | 439 | rb.Push(RESULT_SUCCESS); |
| 395 | rb.PushCopyObjects(event); | 440 | rb.PushCopyObjects(msg_queue->GetMesssageRecieveEvent()); |
| 396 | 441 | ||
| 397 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 442 | LOG_DEBUG(Service_AM, "called"); |
| 398 | } | 443 | } |
| 399 | 444 | ||
| 400 | void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) { | 445 | void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) { |
| 401 | IPC::ResponseBuilder rb{ctx, 3}; | 446 | IPC::ResponseBuilder rb{ctx, 3}; |
| 402 | rb.Push(RESULT_SUCCESS); | 447 | rb.Push(RESULT_SUCCESS); |
| 403 | rb.Push<u32>(15); | 448 | rb.PushEnum<AppletMessageQueue::AppletMessage>(msg_queue->PopMessage()); |
| 404 | 449 | ||
| 405 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 450 | LOG_DEBUG(Service_AM, "called"); |
| 406 | } | 451 | } |
| 407 | 452 | ||
| 408 | void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) { | 453 | void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) { |
| @@ -414,13 +459,11 @@ void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) { | |||
| 414 | } | 459 | } |
| 415 | 460 | ||
| 416 | void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx) { | 461 | void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx) { |
| 417 | event->Signal(); | ||
| 418 | |||
| 419 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 462 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 420 | rb.Push(RESULT_SUCCESS); | 463 | rb.Push(RESULT_SUCCESS); |
| 421 | rb.PushCopyObjects(event); | 464 | rb.PushCopyObjects(msg_queue->GetOperationModeChangedEvent()); |
| 422 | 465 | ||
| 423 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 466 | LOG_DEBUG(Service_AM, "called"); |
| 424 | } | 467 | } |
| 425 | 468 | ||
| 426 | void ICommonStateGetter::GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx) { | 469 | void ICommonStateGetter::GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx) { |
| @@ -444,7 +487,7 @@ void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) { | |||
| 444 | rb.Push(RESULT_SUCCESS); | 487 | rb.Push(RESULT_SUCCESS); |
| 445 | rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld)); | 488 | rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld)); |
| 446 | 489 | ||
| 447 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 490 | LOG_DEBUG(Service_AM, "called"); |
| 448 | } | 491 | } |
| 449 | 492 | ||
| 450 | void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) { | 493 | void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) { |
| @@ -454,7 +497,7 @@ void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) { | |||
| 454 | rb.Push(static_cast<u32>(use_docked_mode ? APM::PerformanceMode::Docked | 497 | rb.Push(static_cast<u32>(use_docked_mode ? APM::PerformanceMode::Docked |
| 455 | : APM::PerformanceMode::Handheld)); | 498 | : APM::PerformanceMode::Handheld)); |
| 456 | 499 | ||
| 457 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 500 | LOG_DEBUG(Service_AM, "called"); |
| 458 | } | 501 | } |
| 459 | 502 | ||
| 460 | class IStorageAccessor final : public ServiceFramework<IStorageAccessor> { | 503 | class IStorageAccessor final : public ServiceFramework<IStorageAccessor> { |
| @@ -840,8 +883,12 @@ void IApplicationFunctions::GetPseudoDeviceId(Kernel::HLERequestContext& ctx) { | |||
| 840 | 883 | ||
| 841 | void InstallInterfaces(SM::ServiceManager& service_manager, | 884 | void InstallInterfaces(SM::ServiceManager& service_manager, |
| 842 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger) { | 885 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger) { |
| 843 | std::make_shared<AppletAE>(nvflinger)->InstallAsService(service_manager); | 886 | auto message_queue = std::make_shared<AppletMessageQueue>(); |
| 844 | std::make_shared<AppletOE>(nvflinger)->InstallAsService(service_manager); | 887 | message_queue->PushMessage( |
| 888 | AppletMessageQueue::AppletMessage::FocusStateChanged); // Needed on game boot | ||
| 889 | |||
| 890 | std::make_shared<AppletAE>(nvflinger, message_queue)->InstallAsService(service_manager); | ||
| 891 | std::make_shared<AppletOE>(nvflinger, message_queue)->InstallAsService(service_manager); | ||
| 845 | std::make_shared<IdleSys>()->InstallAsService(service_manager); | 892 | std::make_shared<IdleSys>()->InstallAsService(service_manager); |
| 846 | std::make_shared<OMM>()->InstallAsService(service_manager); | 893 | std::make_shared<OMM>()->InstallAsService(service_manager); |
| 847 | std::make_shared<SPSM>()->InstallAsService(service_manager); | 894 | std::make_shared<SPSM>()->InstallAsService(service_manager); |
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 095f94851..2f1c20bce 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <queue> | ||
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | 10 | ||
| 10 | namespace Kernel { | 11 | namespace Kernel { |
| @@ -39,6 +40,31 @@ enum SystemLanguage { | |||
| 39 | TraditionalChinese = 16, | 40 | TraditionalChinese = 16, |
| 40 | }; | 41 | }; |
| 41 | 42 | ||
| 43 | class AppletMessageQueue { | ||
| 44 | public: | ||
| 45 | enum class AppletMessage : u32 { | ||
| 46 | NoMessage = 0, | ||
| 47 | FocusStateChanged = 15, | ||
| 48 | OperationModeChanged = 30, | ||
| 49 | PerformanceModeChanged = 31, | ||
| 50 | }; | ||
| 51 | |||
| 52 | AppletMessageQueue(); | ||
| 53 | ~AppletMessageQueue(); | ||
| 54 | |||
| 55 | const Kernel::SharedPtr<Kernel::Event>& GetMesssageRecieveEvent() const; | ||
| 56 | const Kernel::SharedPtr<Kernel::Event>& GetOperationModeChangedEvent() const; | ||
| 57 | void PushMessage(AppletMessage msg); | ||
| 58 | AppletMessage PopMessage(); | ||
| 59 | std::size_t GetMessageCount() const; | ||
| 60 | void OperationModeChanged(); | ||
| 61 | |||
| 62 | private: | ||
| 63 | std::queue<AppletMessage> messages; | ||
| 64 | Kernel::SharedPtr<Kernel::Event> on_new_message; | ||
| 65 | Kernel::SharedPtr<Kernel::Event> on_operation_mode_changed; | ||
| 66 | }; | ||
| 67 | |||
| 42 | class IWindowController final : public ServiceFramework<IWindowController> { | 68 | class IWindowController final : public ServiceFramework<IWindowController> { |
| 43 | public: | 69 | public: |
| 44 | IWindowController(); | 70 | IWindowController(); |
| @@ -102,7 +128,7 @@ private: | |||
| 102 | 128 | ||
| 103 | class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> { | 129 | class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> { |
| 104 | public: | 130 | public: |
| 105 | ICommonStateGetter(); | 131 | explicit ICommonStateGetter(std::shared_ptr<AppletMessageQueue> msg_queue); |
| 106 | ~ICommonStateGetter() override; | 132 | ~ICommonStateGetter() override; |
| 107 | 133 | ||
| 108 | private: | 134 | private: |
| @@ -126,6 +152,7 @@ private: | |||
| 126 | void GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx); | 152 | void GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx); |
| 127 | 153 | ||
| 128 | Kernel::SharedPtr<Kernel::Event> event; | 154 | Kernel::SharedPtr<Kernel::Event> event; |
| 155 | std::shared_ptr<AppletMessageQueue> msg_queue; | ||
| 129 | }; | 156 | }; |
| 130 | 157 | ||
| 131 | class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> { | 158 | class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> { |
diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cpp index 68ea778e8..ec93e3529 100644 --- a/src/core/hle/service/am/applet_ae.cpp +++ b/src/core/hle/service/am/applet_ae.cpp | |||
| @@ -12,8 +12,10 @@ namespace Service::AM { | |||
| 12 | 12 | ||
| 13 | class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> { | 13 | class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> { |
| 14 | public: | 14 | public: |
| 15 | explicit ILibraryAppletProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) | 15 | explicit ILibraryAppletProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, |
| 16 | : ServiceFramework("ILibraryAppletProxy"), nvflinger(std::move(nvflinger)) { | 16 | std::shared_ptr<AppletMessageQueue> msg_queue) |
| 17 | : ServiceFramework("ILibraryAppletProxy"), nvflinger(std::move(nvflinger)), | ||
| 18 | msg_queue(std::move(msg_queue)) { | ||
| 17 | static const FunctionInfo functions[] = { | 19 | static const FunctionInfo functions[] = { |
| 18 | {0, &ILibraryAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"}, | 20 | {0, &ILibraryAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"}, |
| 19 | {1, &ILibraryAppletProxy::GetSelfController, "GetSelfController"}, | 21 | {1, &ILibraryAppletProxy::GetSelfController, "GetSelfController"}, |
| @@ -32,7 +34,7 @@ private: | |||
| 32 | void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { | 34 | void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { |
| 33 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 35 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 34 | rb.Push(RESULT_SUCCESS); | 36 | rb.Push(RESULT_SUCCESS); |
| 35 | rb.PushIpcInterface<ICommonStateGetter>(); | 37 | rb.PushIpcInterface<ICommonStateGetter>(msg_queue); |
| 36 | LOG_DEBUG(Service_AM, "called"); | 38 | LOG_DEBUG(Service_AM, "called"); |
| 37 | } | 39 | } |
| 38 | 40 | ||
| @@ -93,12 +95,15 @@ private: | |||
| 93 | } | 95 | } |
| 94 | 96 | ||
| 95 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; | 97 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; |
| 98 | std::shared_ptr<AppletMessageQueue> msg_queue; | ||
| 96 | }; | 99 | }; |
| 97 | 100 | ||
| 98 | class ISystemAppletProxy final : public ServiceFramework<ISystemAppletProxy> { | 101 | class ISystemAppletProxy final : public ServiceFramework<ISystemAppletProxy> { |
| 99 | public: | 102 | public: |
| 100 | explicit ISystemAppletProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) | 103 | explicit ISystemAppletProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, |
| 101 | : ServiceFramework("ISystemAppletProxy"), nvflinger(std::move(nvflinger)) { | 104 | std::shared_ptr<AppletMessageQueue> msg_queue) |
| 105 | : ServiceFramework("ISystemAppletProxy"), nvflinger(std::move(nvflinger)), | ||
| 106 | msg_queue(std::move(msg_queue)) { | ||
| 102 | static const FunctionInfo functions[] = { | 107 | static const FunctionInfo functions[] = { |
| 103 | {0, &ISystemAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"}, | 108 | {0, &ISystemAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"}, |
| 104 | {1, &ISystemAppletProxy::GetSelfController, "GetSelfController"}, | 109 | {1, &ISystemAppletProxy::GetSelfController, "GetSelfController"}, |
| @@ -119,7 +124,7 @@ private: | |||
| 119 | void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { | 124 | void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { |
| 120 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 125 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 121 | rb.Push(RESULT_SUCCESS); | 126 | rb.Push(RESULT_SUCCESS); |
| 122 | rb.PushIpcInterface<ICommonStateGetter>(); | 127 | rb.PushIpcInterface<ICommonStateGetter>(msg_queue); |
| 123 | LOG_DEBUG(Service_AM, "called"); | 128 | LOG_DEBUG(Service_AM, "called"); |
| 124 | } | 129 | } |
| 125 | 130 | ||
| @@ -186,31 +191,34 @@ private: | |||
| 186 | LOG_DEBUG(Service_AM, "called"); | 191 | LOG_DEBUG(Service_AM, "called"); |
| 187 | } | 192 | } |
| 188 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; | 193 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; |
| 194 | std::shared_ptr<AppletMessageQueue> msg_queue; | ||
| 189 | }; | 195 | }; |
| 190 | 196 | ||
| 191 | void AppletAE::OpenSystemAppletProxy(Kernel::HLERequestContext& ctx) { | 197 | void AppletAE::OpenSystemAppletProxy(Kernel::HLERequestContext& ctx) { |
| 192 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 198 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 193 | rb.Push(RESULT_SUCCESS); | 199 | rb.Push(RESULT_SUCCESS); |
| 194 | rb.PushIpcInterface<ISystemAppletProxy>(nvflinger); | 200 | rb.PushIpcInterface<ISystemAppletProxy>(nvflinger, msg_queue); |
| 195 | LOG_DEBUG(Service_AM, "called"); | 201 | LOG_DEBUG(Service_AM, "called"); |
| 196 | } | 202 | } |
| 197 | 203 | ||
| 198 | void AppletAE::OpenLibraryAppletProxy(Kernel::HLERequestContext& ctx) { | 204 | void AppletAE::OpenLibraryAppletProxy(Kernel::HLERequestContext& ctx) { |
| 199 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 205 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 200 | rb.Push(RESULT_SUCCESS); | 206 | rb.Push(RESULT_SUCCESS); |
| 201 | rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger); | 207 | rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger, msg_queue); |
| 202 | LOG_DEBUG(Service_AM, "called"); | 208 | LOG_DEBUG(Service_AM, "called"); |
| 203 | } | 209 | } |
| 204 | 210 | ||
| 205 | void AppletAE::OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx) { | 211 | void AppletAE::OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx) { |
| 206 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 212 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 207 | rb.Push(RESULT_SUCCESS); | 213 | rb.Push(RESULT_SUCCESS); |
| 208 | rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger); | 214 | rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger, msg_queue); |
| 209 | LOG_DEBUG(Service_AM, "called"); | 215 | LOG_DEBUG(Service_AM, "called"); |
| 210 | } | 216 | } |
| 211 | 217 | ||
| 212 | AppletAE::AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) | 218 | AppletAE::AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, |
| 213 | : ServiceFramework("appletAE"), nvflinger(std::move(nvflinger)) { | 219 | std::shared_ptr<AppletMessageQueue> msg_queue) |
| 220 | : ServiceFramework("appletAE"), nvflinger(std::move(nvflinger)), | ||
| 221 | msg_queue(std::move(msg_queue)) { | ||
| 214 | // clang-format off | 222 | // clang-format off |
| 215 | static const FunctionInfo functions[] = { | 223 | static const FunctionInfo functions[] = { |
| 216 | {100, &AppletAE::OpenSystemAppletProxy, "OpenSystemAppletProxy"}, | 224 | {100, &AppletAE::OpenSystemAppletProxy, "OpenSystemAppletProxy"}, |
| @@ -228,4 +236,8 @@ AppletAE::AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) | |||
| 228 | 236 | ||
| 229 | AppletAE::~AppletAE() = default; | 237 | AppletAE::~AppletAE() = default; |
| 230 | 238 | ||
| 239 | const std::shared_ptr<AppletMessageQueue>& AppletAE::GetMessageQueue() const { | ||
| 240 | return msg_queue; | ||
| 241 | } | ||
| 242 | |||
| 231 | } // namespace Service::AM | 243 | } // namespace Service::AM |
diff --git a/src/core/hle/service/am/applet_ae.h b/src/core/hle/service/am/applet_ae.h index 1ed77baa4..902db2665 100644 --- a/src/core/hle/service/am/applet_ae.h +++ b/src/core/hle/service/am/applet_ae.h | |||
| @@ -17,15 +17,19 @@ namespace AM { | |||
| 17 | 17 | ||
| 18 | class AppletAE final : public ServiceFramework<AppletAE> { | 18 | class AppletAE final : public ServiceFramework<AppletAE> { |
| 19 | public: | 19 | public: |
| 20 | explicit AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger); | 20 | explicit AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, |
| 21 | std::shared_ptr<AppletMessageQueue> msg_queue); | ||
| 21 | ~AppletAE() override; | 22 | ~AppletAE() override; |
| 22 | 23 | ||
| 24 | const std::shared_ptr<AppletMessageQueue>& GetMessageQueue() const; | ||
| 25 | |||
| 23 | private: | 26 | private: |
| 24 | void OpenSystemAppletProxy(Kernel::HLERequestContext& ctx); | 27 | void OpenSystemAppletProxy(Kernel::HLERequestContext& ctx); |
| 25 | void OpenLibraryAppletProxy(Kernel::HLERequestContext& ctx); | 28 | void OpenLibraryAppletProxy(Kernel::HLERequestContext& ctx); |
| 26 | void OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx); | 29 | void OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx); |
| 27 | 30 | ||
| 28 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; | 31 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; |
| 32 | std::shared_ptr<AppletMessageQueue> msg_queue; | ||
| 29 | }; | 33 | }; |
| 30 | 34 | ||
| 31 | } // namespace AM | 35 | } // namespace AM |
diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp index 60717afd9..20c8d5fff 100644 --- a/src/core/hle/service/am/applet_oe.cpp +++ b/src/core/hle/service/am/applet_oe.cpp | |||
| @@ -12,8 +12,10 @@ namespace Service::AM { | |||
| 12 | 12 | ||
| 13 | class IApplicationProxy final : public ServiceFramework<IApplicationProxy> { | 13 | class IApplicationProxy final : public ServiceFramework<IApplicationProxy> { |
| 14 | public: | 14 | public: |
| 15 | explicit IApplicationProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) | 15 | explicit IApplicationProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, |
| 16 | : ServiceFramework("IApplicationProxy"), nvflinger(std::move(nvflinger)) { | 16 | std::shared_ptr<AppletMessageQueue> msg_queue) |
| 17 | : ServiceFramework("IApplicationProxy"), nvflinger(std::move(nvflinger)), | ||
| 18 | msg_queue(std::move(msg_queue)) { | ||
| 17 | // clang-format off | 19 | // clang-format off |
| 18 | static const FunctionInfo functions[] = { | 20 | static const FunctionInfo functions[] = { |
| 19 | {0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"}, | 21 | {0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"}, |
| @@ -70,7 +72,7 @@ private: | |||
| 70 | void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { | 72 | void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { |
| 71 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 73 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 72 | rb.Push(RESULT_SUCCESS); | 74 | rb.Push(RESULT_SUCCESS); |
| 73 | rb.PushIpcInterface<ICommonStateGetter>(); | 75 | rb.PushIpcInterface<ICommonStateGetter>(msg_queue); |
| 74 | LOG_DEBUG(Service_AM, "called"); | 76 | LOG_DEBUG(Service_AM, "called"); |
| 75 | } | 77 | } |
| 76 | 78 | ||
| @@ -89,17 +91,20 @@ private: | |||
| 89 | } | 91 | } |
| 90 | 92 | ||
| 91 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; | 93 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; |
| 94 | std::shared_ptr<AppletMessageQueue> msg_queue; | ||
| 92 | }; | 95 | }; |
| 93 | 96 | ||
| 94 | void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) { | 97 | void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) { |
| 95 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 98 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 96 | rb.Push(RESULT_SUCCESS); | 99 | rb.Push(RESULT_SUCCESS); |
| 97 | rb.PushIpcInterface<IApplicationProxy>(nvflinger); | 100 | rb.PushIpcInterface<IApplicationProxy>(nvflinger, msg_queue); |
| 98 | LOG_DEBUG(Service_AM, "called"); | 101 | LOG_DEBUG(Service_AM, "called"); |
| 99 | } | 102 | } |
| 100 | 103 | ||
| 101 | AppletOE::AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) | 104 | AppletOE::AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, |
| 102 | : ServiceFramework("appletOE"), nvflinger(std::move(nvflinger)) { | 105 | std::shared_ptr<AppletMessageQueue> msg_queue) |
| 106 | : ServiceFramework("appletOE"), nvflinger(std::move(nvflinger)), | ||
| 107 | msg_queue(std::move(msg_queue)) { | ||
| 103 | static const FunctionInfo functions[] = { | 108 | static const FunctionInfo functions[] = { |
| 104 | {0, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"}, | 109 | {0, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"}, |
| 105 | }; | 110 | }; |
| @@ -108,4 +113,8 @@ AppletOE::AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) | |||
| 108 | 113 | ||
| 109 | AppletOE::~AppletOE() = default; | 114 | AppletOE::~AppletOE() = default; |
| 110 | 115 | ||
| 116 | const std::shared_ptr<AppletMessageQueue>& AppletOE::GetMessageQueue() const { | ||
| 117 | return msg_queue; | ||
| 118 | } | ||
| 119 | |||
| 111 | } // namespace Service::AM | 120 | } // namespace Service::AM |
diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.h index 60cfdfd9d..bbd0108ef 100644 --- a/src/core/hle/service/am/applet_oe.h +++ b/src/core/hle/service/am/applet_oe.h | |||
| @@ -17,13 +17,17 @@ namespace AM { | |||
| 17 | 17 | ||
| 18 | class AppletOE final : public ServiceFramework<AppletOE> { | 18 | class AppletOE final : public ServiceFramework<AppletOE> { |
| 19 | public: | 19 | public: |
| 20 | explicit AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger); | 20 | explicit AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, |
| 21 | std::shared_ptr<AppletMessageQueue> msg_queue); | ||
| 21 | ~AppletOE() override; | 22 | ~AppletOE() override; |
| 22 | 23 | ||
| 24 | const std::shared_ptr<AppletMessageQueue>& GetMessageQueue() const; | ||
| 25 | |||
| 23 | private: | 26 | private: |
| 24 | void OpenApplicationProxy(Kernel::HLERequestContext& ctx); | 27 | void OpenApplicationProxy(Kernel::HLERequestContext& ctx); |
| 25 | 28 | ||
| 26 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; | 29 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; |
| 30 | std::shared_ptr<AppletMessageQueue> msg_queue; | ||
| 27 | }; | 31 | }; |
| 28 | 32 | ||
| 29 | } // namespace AM | 33 | } // namespace AM |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 1ef789bd0..ff9b64be4 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -392,8 +392,10 @@ std::size_t Controller_NPad::GetSupportedNPadIdTypesSize() const { | |||
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | void Controller_NPad::SetHoldType(NpadHoldType joy_hold_type) { | 394 | void Controller_NPad::SetHoldType(NpadHoldType joy_hold_type) { |
| 395 | styleset_changed_event->Signal(); | ||
| 395 | hold_type = joy_hold_type; | 396 | hold_type = joy_hold_type; |
| 396 | } | 397 | } |
| 398 | |||
| 397 | Controller_NPad::NpadHoldType Controller_NPad::GetHoldType() const { | 399 | Controller_NPad::NpadHoldType Controller_NPad::GetHoldType() const { |
| 398 | return hold_type; | 400 | return hold_type; |
| 399 | } | 401 | } |
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 0b1cc1290..a780215c1 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -21,6 +21,7 @@ add_library(video_core STATIC | |||
| 21 | macro_interpreter.h | 21 | macro_interpreter.h |
| 22 | memory_manager.cpp | 22 | memory_manager.cpp |
| 23 | memory_manager.h | 23 | memory_manager.h |
| 24 | rasterizer_cache.cpp | ||
| 24 | rasterizer_cache.h | 25 | rasterizer_cache.h |
| 25 | rasterizer_interface.h | 26 | rasterizer_interface.h |
| 26 | renderer_base.cpp | 27 | renderer_base.cpp |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 2cd595f26..5ae836aca 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -108,8 +108,16 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { | |||
| 108 | debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr); | 108 | debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | u32 old = regs.reg_array[method]; | ||
| 111 | regs.reg_array[method] = value; | 112 | regs.reg_array[method] = value; |
| 112 | 113 | ||
| 114 | if (value != old) { | ||
| 115 | if (method >= MAXWELL3D_REG_INDEX(vertex_attrib_format) && | ||
| 116 | method < MAXWELL3D_REG_INDEX(vertex_attrib_format) + regs.vertex_attrib_format.size()) { | ||
| 117 | dirty_flags.vertex_attrib_format = true; | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 113 | switch (method) { | 121 | switch (method) { |
| 114 | case MAXWELL3D_REG_INDEX(macros.data): { | 122 | case MAXWELL3D_REG_INDEX(macros.data): { |
| 115 | ProcessMacroUpload(value); | 123 | ProcessMacroUpload(value); |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 0509ba3a2..557795d0f 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -1004,6 +1004,12 @@ public: | |||
| 1004 | State state{}; | 1004 | State state{}; |
| 1005 | MemoryManager& memory_manager; | 1005 | MemoryManager& memory_manager; |
| 1006 | 1006 | ||
| 1007 | struct DirtyFlags { | ||
| 1008 | bool vertex_attrib_format = true; | ||
| 1009 | }; | ||
| 1010 | |||
| 1011 | DirtyFlags dirty_flags; | ||
| 1012 | |||
| 1007 | /// Reads a register value located at the input method address | 1013 | /// Reads a register value located at the input method address |
| 1008 | u32 GetRegisterValue(u32 method) const; | 1014 | u32 GetRegisterValue(u32 method) const; |
| 1009 | 1015 | ||
diff --git a/src/video_core/rasterizer_cache.cpp b/src/video_core/rasterizer_cache.cpp new file mode 100644 index 000000000..093b2cdf4 --- /dev/null +++ b/src/video_core/rasterizer_cache.cpp | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | // Copyright 2018 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "video_core/rasterizer_cache.h" | ||
| 6 | |||
| 7 | RasterizerCacheObject::~RasterizerCacheObject() = default; | ||
diff --git a/src/video_core/rasterizer_cache.h b/src/video_core/rasterizer_cache.h index 0a3b3951e..d999c92fa 100644 --- a/src/video_core/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache.h | |||
| @@ -17,6 +17,8 @@ | |||
| 17 | 17 | ||
| 18 | class RasterizerCacheObject { | 18 | class RasterizerCacheObject { |
| 19 | public: | 19 | public: |
| 20 | virtual ~RasterizerCacheObject(); | ||
| 21 | |||
| 20 | /// Gets the address of the shader in guest memory, required for cache management | 22 | /// Gets the address of the shader in guest memory, required for cache management |
| 21 | virtual VAddr GetAddr() const = 0; | 23 | virtual VAddr GetAddr() const = 0; |
| 22 | 24 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index bb263b6aa..1bdd4c054 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -33,7 +33,8 @@ using Maxwell = Tegra::Engines::Maxwell3D::Regs; | |||
| 33 | using PixelFormat = VideoCore::Surface::PixelFormat; | 33 | using PixelFormat = VideoCore::Surface::PixelFormat; |
| 34 | using SurfaceType = VideoCore::Surface::SurfaceType; | 34 | using SurfaceType = VideoCore::Surface::SurfaceType; |
| 35 | 35 | ||
| 36 | MICROPROFILE_DEFINE(OpenGL_VAO, "OpenGL", "Vertex Array Setup", MP_RGB(128, 128, 192)); | 36 | MICROPROFILE_DEFINE(OpenGL_VAO, "OpenGL", "Vertex Format Setup", MP_RGB(128, 128, 192)); |
| 37 | MICROPROFILE_DEFINE(OpenGL_VB, "OpenGL", "Vertex Buffer Setup", MP_RGB(128, 128, 192)); | ||
| 37 | MICROPROFILE_DEFINE(OpenGL_Shader, "OpenGL", "Shader Setup", MP_RGB(128, 128, 192)); | 38 | MICROPROFILE_DEFINE(OpenGL_Shader, "OpenGL", "Shader Setup", MP_RGB(128, 128, 192)); |
| 38 | MICROPROFILE_DEFINE(OpenGL_UBO, "OpenGL", "Const Buffer Setup", MP_RGB(128, 128, 192)); | 39 | MICROPROFILE_DEFINE(OpenGL_UBO, "OpenGL", "Const Buffer Setup", MP_RGB(128, 128, 192)); |
| 39 | MICROPROFILE_DEFINE(OpenGL_Index, "OpenGL", "Index Buffer Setup", MP_RGB(128, 128, 192)); | 40 | MICROPROFILE_DEFINE(OpenGL_Index, "OpenGL", "Index Buffer Setup", MP_RGB(128, 128, 192)); |
| @@ -122,11 +123,16 @@ RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, ScreenInfo | |||
| 122 | 123 | ||
| 123 | RasterizerOpenGL::~RasterizerOpenGL() {} | 124 | RasterizerOpenGL::~RasterizerOpenGL() {} |
| 124 | 125 | ||
| 125 | void RasterizerOpenGL::SetupVertexArrays() { | 126 | void RasterizerOpenGL::SetupVertexFormat() { |
| 126 | MICROPROFILE_SCOPE(OpenGL_VAO); | 127 | auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); |
| 127 | const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); | ||
| 128 | const auto& regs = gpu.regs; | 128 | const auto& regs = gpu.regs; |
| 129 | 129 | ||
| 130 | if (!gpu.dirty_flags.vertex_attrib_format) | ||
| 131 | return; | ||
| 132 | gpu.dirty_flags.vertex_attrib_format = false; | ||
| 133 | |||
| 134 | MICROPROFILE_SCOPE(OpenGL_VAO); | ||
| 135 | |||
| 130 | auto [iter, is_cache_miss] = vertex_array_cache.try_emplace(regs.vertex_attrib_format); | 136 | auto [iter, is_cache_miss] = vertex_array_cache.try_emplace(regs.vertex_attrib_format); |
| 131 | auto& VAO = iter->second; | 137 | auto& VAO = iter->second; |
| 132 | 138 | ||
| @@ -175,8 +181,13 @@ void RasterizerOpenGL::SetupVertexArrays() { | |||
| 175 | } | 181 | } |
| 176 | } | 182 | } |
| 177 | state.draw.vertex_array = VAO.handle; | 183 | state.draw.vertex_array = VAO.handle; |
| 178 | state.draw.vertex_buffer = buffer_cache.GetHandle(); | ||
| 179 | state.Apply(); | 184 | state.Apply(); |
| 185 | } | ||
| 186 | |||
| 187 | void RasterizerOpenGL::SetupVertexBuffer() { | ||
| 188 | MICROPROFILE_SCOPE(OpenGL_VB); | ||
| 189 | const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); | ||
| 190 | const auto& regs = gpu.regs; | ||
| 180 | 191 | ||
| 181 | // Upload all guest vertex arrays sequentially to our buffer | 192 | // Upload all guest vertex arrays sequentially to our buffer |
| 182 | for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) { | 193 | for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) { |
| @@ -203,6 +214,9 @@ void RasterizerOpenGL::SetupVertexArrays() { | |||
| 203 | glVertexBindingDivisor(index, 0); | 214 | glVertexBindingDivisor(index, 0); |
| 204 | } | 215 | } |
| 205 | } | 216 | } |
| 217 | |||
| 218 | // Implicit set by glBindVertexBuffer. Stupid glstate handling... | ||
| 219 | state.draw.vertex_buffer = buffer_cache.GetHandle(); | ||
| 206 | } | 220 | } |
| 207 | 221 | ||
| 208 | DrawParameters RasterizerOpenGL::SetupDraw() { | 222 | DrawParameters RasterizerOpenGL::SetupDraw() { |
| @@ -620,7 +634,8 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 620 | 634 | ||
| 621 | buffer_cache.Map(buffer_size); | 635 | buffer_cache.Map(buffer_size); |
| 622 | 636 | ||
| 623 | SetupVertexArrays(); | 637 | SetupVertexFormat(); |
| 638 | SetupVertexBuffer(); | ||
| 624 | DrawParameters params = SetupDraw(); | 639 | DrawParameters params = SetupDraw(); |
| 625 | SetupShaders(params.primitive_mode); | 640 | SetupShaders(params.primitive_mode); |
| 626 | 641 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 60e783803..5eee5f088 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -207,7 +207,8 @@ private: | |||
| 207 | 207 | ||
| 208 | std::size_t CalculateIndexBufferSize() const; | 208 | std::size_t CalculateIndexBufferSize() const; |
| 209 | 209 | ||
| 210 | void SetupVertexArrays(); | 210 | void SetupVertexFormat(); |
| 211 | void SetupVertexBuffer(); | ||
| 211 | 212 | ||
| 212 | DrawParameters SetupDraw(); | 213 | DrawParameters SetupDraw(); |
| 213 | 214 | ||
diff --git a/src/video_core/renderer_opengl/gl_resource_manager.cpp b/src/video_core/renderer_opengl/gl_resource_manager.cpp index 161318c5f..c17d5ac00 100644 --- a/src/video_core/renderer_opengl/gl_resource_manager.cpp +++ b/src/video_core/renderer_opengl/gl_resource_manager.cpp | |||
| @@ -10,10 +10,8 @@ | |||
| 10 | #include "video_core/renderer_opengl/gl_shader_util.h" | 10 | #include "video_core/renderer_opengl/gl_shader_util.h" |
| 11 | #include "video_core/renderer_opengl/gl_state.h" | 11 | #include "video_core/renderer_opengl/gl_state.h" |
| 12 | 12 | ||
| 13 | MICROPROFILE_DEFINE(OpenGL_ResourceCreation, "OpenGL", "Resource Creation", | 13 | MICROPROFILE_DEFINE(OpenGL_ResourceCreation, "OpenGL", "Resource Creation", MP_RGB(128, 128, 192)); |
| 14 | MP_RGB(128, 128, 192)); | 14 | MICROPROFILE_DEFINE(OpenGL_ResourceDeletion, "OpenGL", "Resource Deletion", MP_RGB(128, 128, 192)); |
| 15 | MICROPROFILE_DEFINE(OpenGL_ResourceDeletion, "OpenGL", "Resource Deletion", | ||
| 16 | MP_RGB(128, 128, 192)); | ||
| 17 | 15 | ||
| 18 | namespace OpenGL { | 16 | namespace OpenGL { |
| 19 | 17 | ||
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 537d6e576..b322258a0 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -3,6 +3,10 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/core.h" | 5 | #include "core/core.h" |
| 6 | #include "core/hle/service/am/am.h" | ||
| 7 | #include "core/hle/service/am/applet_ae.h" | ||
| 8 | #include "core/hle/service/am/applet_oe.h" | ||
| 9 | #include "core/hle/service/sm/sm.h" | ||
| 6 | #include "core/settings.h" | 10 | #include "core/settings.h" |
| 7 | #include "ui_configure_general.h" | 11 | #include "ui_configure_general.h" |
| 8 | #include "yuzu/configuration/configure_general.h" | 12 | #include "yuzu/configuration/configure_general.h" |
| @@ -20,7 +24,6 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) | |||
| 20 | this->setConfiguration(); | 24 | this->setConfiguration(); |
| 21 | 25 | ||
| 22 | ui->use_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); | 26 | ui->use_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); |
| 23 | ui->use_docked_mode->setEnabled(!Core::System::GetInstance().IsPoweredOn()); | ||
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | ConfigureGeneral::~ConfigureGeneral() = default; | 29 | ConfigureGeneral::~ConfigureGeneral() = default; |
| @@ -38,6 +41,30 @@ void ConfigureGeneral::PopulateHotkeyList(const HotkeyRegistry& registry) { | |||
| 38 | ui->widget->Populate(registry); | 41 | ui->widget->Populate(registry); |
| 39 | } | 42 | } |
| 40 | 43 | ||
| 44 | void ConfigureGeneral::OnDockedModeChanged(bool last_state, bool new_state) { | ||
| 45 | if (last_state == new_state) { | ||
| 46 | return; | ||
| 47 | } | ||
| 48 | |||
| 49 | Core::System& system{Core::System::GetInstance()}; | ||
| 50 | Service::SM::ServiceManager& sm = system.ServiceManager(); | ||
| 51 | |||
| 52 | // Message queue is shared between these services, we just need to signal an operation | ||
| 53 | // change to one and it will handle both automatically | ||
| 54 | auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE"); | ||
| 55 | auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE"); | ||
| 56 | bool has_signalled = false; | ||
| 57 | |||
| 58 | if (applet_oe != nullptr) { | ||
| 59 | applet_oe->GetMessageQueue()->OperationModeChanged(); | ||
| 60 | has_signalled = true; | ||
| 61 | } | ||
| 62 | |||
| 63 | if (applet_ae != nullptr && !has_signalled) { | ||
| 64 | applet_ae->GetMessageQueue()->OperationModeChanged(); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 41 | void ConfigureGeneral::applyConfiguration() { | 68 | void ConfigureGeneral::applyConfiguration() { |
| 42 | UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); | 69 | UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); |
| 43 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); | 70 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); |
| @@ -45,6 +72,9 @@ void ConfigureGeneral::applyConfiguration() { | |||
| 45 | ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString(); | 72 | ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString(); |
| 46 | 73 | ||
| 47 | Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked(); | 74 | Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked(); |
| 75 | const bool pre_docked_mode = Settings::values.use_docked_mode; | ||
| 48 | Settings::values.use_docked_mode = ui->use_docked_mode->isChecked(); | 76 | Settings::values.use_docked_mode = ui->use_docked_mode->isChecked(); |
| 77 | OnDockedModeChanged(pre_docked_mode, Settings::values.use_docked_mode); | ||
| 78 | |||
| 49 | Settings::values.enable_nfc = ui->enable_nfc->isChecked(); | 79 | Settings::values.enable_nfc = ui->enable_nfc->isChecked(); |
| 50 | } | 80 | } |
diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index 4770034cc..2210d48da 100644 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h | |||
| @@ -25,6 +25,7 @@ public: | |||
| 25 | 25 | ||
| 26 | private: | 26 | private: |
| 27 | void setConfiguration(); | 27 | void setConfiguration(); |
| 28 | void OnDockedModeChanged(bool last_state, bool new_state); | ||
| 28 | 29 | ||
| 29 | std::unique_ptr<Ui::ConfigureGeneral> ui; | 30 | std::unique_ptr<Ui::ConfigureGeneral> ui; |
| 30 | }; | 31 | }; |