diff options
Diffstat (limited to 'src')
47 files changed, 372 insertions, 112 deletions
diff --git a/src/common/uuid.h b/src/common/uuid.h index f6ad064fb..4d3af8cec 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h | |||
| @@ -40,6 +40,11 @@ struct UUID { | |||
| 40 | uuid = INVALID_UUID; | 40 | uuid = INVALID_UUID; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | // TODO(ogniK): Properly generate a Nintendo ID | ||
| 44 | constexpr u64 GetNintendoID() const { | ||
| 45 | return uuid[0]; | ||
| 46 | } | ||
| 47 | |||
| 43 | std::string Format() const; | 48 | std::string Format() const; |
| 44 | std::string FormatSwitch() const; | 49 | std::string FormatSwitch() const; |
| 45 | }; | 50 | }; |
diff --git a/src/core/hle/kernel/memory/address_space_info.cpp b/src/core/hle/kernel/memory/address_space_info.cpp index 27fae05e7..a523a2502 100644 --- a/src/core/hle/kernel/memory/address_space_info.cpp +++ b/src/core/hle/kernel/memory/address_space_info.cpp | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | // This file references various implementation details from Atmosphère, an open-source firmware for | 5 | // This file references various implementation details from Atmosphere, an open-source firmware for |
| 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphère-NX. | 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX. |
| 7 | 7 | ||
| 8 | #include <array> | 8 | #include <array> |
| 9 | 9 | ||
| @@ -49,18 +49,18 @@ constexpr bool IsAllowedIndexForAddress(std::size_t index) { | |||
| 49 | return index < std::size(AddressSpaceInfos) && AddressSpaceInfos[index].GetAddress() != Invalid; | 49 | return index < std::size(AddressSpaceInfos) && AddressSpaceInfos[index].GetAddress() != Invalid; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | constexpr std::size_t | 52 | constexpr std::array<std::size_t, static_cast<std::size_t>(AddressSpaceInfo::Type::Count)> |
| 53 | AddressSpaceIndices32Bit[static_cast<std::size_t>(AddressSpaceInfo::Type::Count)]{ | 53 | AddressSpaceIndices32Bit{ |
| 54 | 0, 1, 0, 2, 0, 3, | 54 | 0, 1, 0, 2, 0, 3, |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | constexpr std::size_t | 57 | constexpr std::array<std::size_t, static_cast<std::size_t>(AddressSpaceInfo::Type::Count)> |
| 58 | AddressSpaceIndices36Bit[static_cast<std::size_t>(AddressSpaceInfo::Type::Count)]{ | 58 | AddressSpaceIndices36Bit{ |
| 59 | 4, 5, 4, 6, 4, 7, | 59 | 4, 5, 4, 6, 4, 7, |
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | constexpr std::size_t | 62 | constexpr std::array<std::size_t, static_cast<std::size_t>(AddressSpaceInfo::Type::Count)> |
| 63 | AddressSpaceIndices39Bit[static_cast<std::size_t>(AddressSpaceInfo::Type::Count)]{ | 63 | AddressSpaceIndices39Bit{ |
| 64 | 9, 8, 8, 10, 12, 11, | 64 | 9, 8, 8, 10, 12, 11, |
| 65 | }; | 65 | }; |
| 66 | 66 | ||
diff --git a/src/core/hle/kernel/memory/address_space_info.h b/src/core/hle/kernel/memory/address_space_info.h index cc9a6421e..c479890be 100644 --- a/src/core/hle/kernel/memory/address_space_info.h +++ b/src/core/hle/kernel/memory/address_space_info.h | |||
| @@ -2,12 +2,11 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | // This file references various implementation details from Atmosphère, an open-source firmware for | 5 | // This file references various implementation details from Atmosphere, an open-source firmware for |
| 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphère-NX. | 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX. |
| 7 | 7 | ||
| 8 | #pragma once | 8 | #pragma once |
| 9 | 9 | ||
| 10 | #include "common/common_funcs.h" | ||
| 11 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 12 | 11 | ||
| 13 | namespace Kernel::Memory { | 12 | namespace Kernel::Memory { |
diff --git a/src/core/hle/kernel/memory/memory_block.h b/src/core/hle/kernel/memory/memory_block.h index 9db1f7b39..9d7839d08 100644 --- a/src/core/hle/kernel/memory/memory_block.h +++ b/src/core/hle/kernel/memory/memory_block.h | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | // This file references various implementation details from Atmosphère, an open-source firmware for | 5 | // This file references various implementation details from Atmosphere, an open-source firmware for |
| 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphère-NX. | 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX. |
| 7 | 7 | ||
| 8 | #pragma once | 8 | #pragma once |
| 9 | 9 | ||
diff --git a/src/core/hle/kernel/memory/memory_block_manager.cpp b/src/core/hle/kernel/memory/memory_block_manager.cpp index 900395c37..0732fa5a1 100644 --- a/src/core/hle/kernel/memory/memory_block_manager.cpp +++ b/src/core/hle/kernel/memory/memory_block_manager.cpp | |||
| @@ -67,7 +67,6 @@ void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState p | |||
| 67 | MemoryPermission prev_perm, MemoryAttribute prev_attribute, | 67 | MemoryPermission prev_perm, MemoryAttribute prev_attribute, |
| 68 | MemoryState state, MemoryPermission perm, | 68 | MemoryState state, MemoryPermission perm, |
| 69 | MemoryAttribute attribute) { | 69 | MemoryAttribute attribute) { |
| 70 | const std::size_t prev_count{memory_block_tree.size()}; | ||
| 71 | const VAddr end_addr{addr + num_pages * PageSize}; | 70 | const VAddr end_addr{addr + num_pages * PageSize}; |
| 72 | iterator node{memory_block_tree.begin()}; | 71 | iterator node{memory_block_tree.begin()}; |
| 73 | 72 | ||
| @@ -109,7 +108,6 @@ void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState p | |||
| 109 | 108 | ||
| 110 | void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState state, | 109 | void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState state, |
| 111 | MemoryPermission perm, MemoryAttribute attribute) { | 110 | MemoryPermission perm, MemoryAttribute attribute) { |
| 112 | const std::size_t prev_count{memory_block_tree.size()}; | ||
| 113 | const VAddr end_addr{addr + num_pages * PageSize}; | 111 | const VAddr end_addr{addr + num_pages * PageSize}; |
| 114 | iterator node{memory_block_tree.begin()}; | 112 | iterator node{memory_block_tree.begin()}; |
| 115 | 113 | ||
| @@ -145,7 +143,6 @@ void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState s | |||
| 145 | 143 | ||
| 146 | void MemoryBlockManager::UpdateLock(VAddr addr, std::size_t num_pages, LockFunc&& lock_func, | 144 | void MemoryBlockManager::UpdateLock(VAddr addr, std::size_t num_pages, LockFunc&& lock_func, |
| 147 | MemoryPermission perm) { | 145 | MemoryPermission perm) { |
| 148 | const std::size_t prev_count{memory_block_tree.size()}; | ||
| 149 | const VAddr end_addr{addr + num_pages * PageSize}; | 146 | const VAddr end_addr{addr + num_pages * PageSize}; |
| 150 | iterator node{memory_block_tree.begin()}; | 147 | iterator node{memory_block_tree.begin()}; |
| 151 | 148 | ||
diff --git a/src/core/hle/kernel/memory/memory_block_manager.h b/src/core/hle/kernel/memory/memory_block_manager.h index 9451b5df6..6e1d41075 100644 --- a/src/core/hle/kernel/memory/memory_block_manager.h +++ b/src/core/hle/kernel/memory/memory_block_manager.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include <functional> | 7 | #include <functional> |
| 8 | #include <list> | 8 | #include <list> |
| 9 | #include <memory> | ||
| 10 | 9 | ||
| 11 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 12 | #include "core/hle/kernel/memory/memory_block.h" | 11 | #include "core/hle/kernel/memory/memory_block.h" |
diff --git a/src/core/hle/kernel/memory/memory_manager.cpp b/src/core/hle/kernel/memory/memory_manager.cpp index 3cd4f9e85..6b432e1b2 100644 --- a/src/core/hle/kernel/memory/memory_manager.cpp +++ b/src/core/hle/kernel/memory/memory_manager.cpp | |||
| @@ -104,9 +104,9 @@ ResultCode MemoryManager::Allocate(PageLinkedList& page_list, std::size_t num_pa | |||
| 104 | // Ensure that we don't leave anything un-freed | 104 | // Ensure that we don't leave anything un-freed |
| 105 | auto group_guard = detail::ScopeExit([&] { | 105 | auto group_guard = detail::ScopeExit([&] { |
| 106 | for (const auto& it : page_list.Nodes()) { | 106 | for (const auto& it : page_list.Nodes()) { |
| 107 | const auto num_pages{std::min( | 107 | const auto min_num_pages{std::min( |
| 108 | it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)}; | 108 | it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)}; |
| 109 | chosen_manager.Free(it.GetAddress(), num_pages); | 109 | chosen_manager.Free(it.GetAddress(), min_num_pages); |
| 110 | } | 110 | } |
| 111 | }); | 111 | }); |
| 112 | 112 | ||
| @@ -165,9 +165,9 @@ ResultCode MemoryManager::Free(PageLinkedList& page_list, std::size_t num_pages, | |||
| 165 | 165 | ||
| 166 | // Free all of the pages | 166 | // Free all of the pages |
| 167 | for (const auto& it : page_list.Nodes()) { | 167 | for (const auto& it : page_list.Nodes()) { |
| 168 | const auto num_pages{std::min( | 168 | const auto min_num_pages{std::min( |
| 169 | it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)}; | 169 | it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)}; |
| 170 | chosen_manager.Free(it.GetAddress(), num_pages); | 170 | chosen_manager.Free(it.GetAddress(), min_num_pages); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | return RESULT_SUCCESS; | 173 | return RESULT_SUCCESS; |
diff --git a/src/core/hle/kernel/memory/memory_manager.h b/src/core/hle/kernel/memory/memory_manager.h index b078d7a5e..3cf444857 100644 --- a/src/core/hle/kernel/memory/memory_manager.h +++ b/src/core/hle/kernel/memory/memory_manager.h | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <mutex> | 8 | #include <mutex> |
| 9 | 9 | ||
| 10 | #include "common/common_funcs.h" | ||
| 11 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 12 | #include "core/hle/kernel/memory/page_heap.h" | 11 | #include "core/hle/kernel/memory/page_heap.h" |
| 13 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
diff --git a/src/core/hle/kernel/memory/page_heap.cpp b/src/core/hle/kernel/memory/page_heap.cpp index efcbb3cad..0ab1f7205 100644 --- a/src/core/hle/kernel/memory/page_heap.cpp +++ b/src/core/hle/kernel/memory/page_heap.cpp | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | // This file references various implementation details from Atmosphère, an open-source firmware for | 5 | // This file references various implementation details from Atmosphere, an open-source firmware for |
| 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphère-NX. | 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX. |
| 7 | 7 | ||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/hle/kernel/memory/page_heap.h" | 9 | #include "core/hle/kernel/memory/page_heap.h" |
diff --git a/src/core/hle/kernel/memory/page_heap.h b/src/core/hle/kernel/memory/page_heap.h index 380c3f5a1..22b0de860 100644 --- a/src/core/hle/kernel/memory/page_heap.h +++ b/src/core/hle/kernel/memory/page_heap.h | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | // This file references various implementation details from Atmosphère, an open-source firmware for | 5 | // This file references various implementation details from Atmosphere, an open-source firmware for |
| 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphère-NX. | 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX. |
| 7 | 7 | ||
| 8 | #pragma once | 8 | #pragma once |
| 9 | 9 | ||
diff --git a/src/core/hle/kernel/memory/page_linked_list.h b/src/core/hle/kernel/memory/page_linked_list.h index 0668d00c6..45dc13eaf 100644 --- a/src/core/hle/kernel/memory/page_linked_list.h +++ b/src/core/hle/kernel/memory/page_linked_list.h | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include <list> | 7 | #include <list> |
| 8 | 8 | ||
| 9 | #include "common/assert.h" | 9 | #include "common/assert.h" |
| 10 | #include "common/common_funcs.h" | ||
| 11 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 12 | #include "core/hle/kernel/memory/memory_types.h" | 11 | #include "core/hle/kernel/memory/memory_types.h" |
| 13 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
diff --git a/src/core/hle/kernel/memory/page_table.cpp b/src/core/hle/kernel/memory/page_table.cpp index 3281611f8..5d6aac00f 100644 --- a/src/core/hle/kernel/memory/page_table.cpp +++ b/src/core/hle/kernel/memory/page_table.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/scope_exit.h" | 7 | #include "common/scope_exit.h" |
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/device_memory.h" | ||
| 10 | #include "core/hle/kernel/errors.h" | 9 | #include "core/hle/kernel/errors.h" |
| 11 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/kernel/memory/address_space_info.h" | 11 | #include "core/hle/kernel/memory/address_space_info.h" |
diff --git a/src/core/hle/kernel/memory/page_table.h b/src/core/hle/kernel/memory/page_table.h index a867aa050..ce0d38849 100644 --- a/src/core/hle/kernel/memory/page_table.h +++ b/src/core/hle/kernel/memory/page_table.h | |||
| @@ -4,16 +4,15 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <list> | ||
| 8 | #include <memory> | 7 | #include <memory> |
| 9 | #include <mutex> | 8 | #include <mutex> |
| 10 | 9 | ||
| 11 | #include "common/common_funcs.h" | ||
| 12 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 13 | #include "common/page_table.h" | 11 | #include "common/page_table.h" |
| 14 | #include "core/file_sys/program_metadata.h" | 12 | #include "core/file_sys/program_metadata.h" |
| 15 | #include "core/hle/kernel/memory/memory_block.h" | 13 | #include "core/hle/kernel/memory/memory_block.h" |
| 16 | #include "core/hle/kernel/memory/memory_manager.h" | 14 | #include "core/hle/kernel/memory/memory_manager.h" |
| 15 | #include "core/hle/result.h" | ||
| 17 | 16 | ||
| 18 | namespace Core { | 17 | namespace Core { |
| 19 | class System; | 18 | class System; |
diff --git a/src/core/hle/kernel/memory/slab_heap.h b/src/core/hle/kernel/memory/slab_heap.h index be95fc3f7..465eaddb3 100644 --- a/src/core/hle/kernel/memory/slab_heap.h +++ b/src/core/hle/kernel/memory/slab_heap.h | |||
| @@ -2,15 +2,14 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | // This file references various implementation details from Atmosphère, an open-source firmware for | 5 | // This file references various implementation details from Atmosphere, an open-source firmware for |
| 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphère-NX. | 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX. |
| 7 | 7 | ||
| 8 | #pragma once | 8 | #pragma once |
| 9 | 9 | ||
| 10 | #include <atomic> | 10 | #include <atomic> |
| 11 | 11 | ||
| 12 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 13 | #include "common/common_funcs.h" | ||
| 14 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 15 | 14 | ||
| 16 | namespace Kernel::Memory { | 15 | namespace Kernel::Memory { |
diff --git a/src/core/hle/kernel/memory/system_control.cpp b/src/core/hle/kernel/memory/system_control.cpp index 9cae3c6cb..2f98e9c4c 100644 --- a/src/core/hle/kernel/memory/system_control.cpp +++ b/src/core/hle/kernel/memory/system_control.cpp | |||
| @@ -2,8 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <random> | 5 | #include <random> |
| 8 | 6 | ||
| 9 | #include "core/hle/kernel/memory/system_control.h" | 7 | #include "core/hle/kernel/memory/system_control.h" |
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 9a7992f58..630a8b048 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -228,7 +228,8 @@ public: | |||
| 228 | 228 | ||
| 229 | class IManagerForApplication final : public ServiceFramework<IManagerForApplication> { | 229 | class IManagerForApplication final : public ServiceFramework<IManagerForApplication> { |
| 230 | public: | 230 | public: |
| 231 | IManagerForApplication() : ServiceFramework("IManagerForApplication") { | 231 | explicit IManagerForApplication(Common::UUID user_id) |
| 232 | : ServiceFramework("IManagerForApplication"), user_id(user_id) { | ||
| 232 | // clang-format off | 233 | // clang-format off |
| 233 | static const FunctionInfo functions[] = { | 234 | static const FunctionInfo functions[] = { |
| 234 | {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"}, | 235 | {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"}, |
| @@ -254,12 +255,14 @@ private: | |||
| 254 | } | 255 | } |
| 255 | 256 | ||
| 256 | void GetAccountId(Kernel::HLERequestContext& ctx) { | 257 | void GetAccountId(Kernel::HLERequestContext& ctx) { |
| 257 | LOG_WARNING(Service_ACC, "(STUBBED) called"); | 258 | LOG_DEBUG(Service_ACC, "called"); |
| 258 | // Should return a nintendo account ID | 259 | |
| 259 | IPC::ResponseBuilder rb{ctx, 4}; | 260 | IPC::ResponseBuilder rb{ctx, 4}; |
| 260 | rb.Push(RESULT_SUCCESS); | 261 | rb.Push(RESULT_SUCCESS); |
| 261 | rb.PushRaw<u64>(1); | 262 | rb.PushRaw<u64>(user_id.GetNintendoID()); |
| 262 | } | 263 | } |
| 264 | |||
| 265 | Common::UUID user_id; | ||
| 263 | }; | 266 | }; |
| 264 | 267 | ||
| 265 | void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) { | 268 | void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) { |
| @@ -382,7 +385,7 @@ void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestCo | |||
| 382 | LOG_DEBUG(Service_ACC, "called"); | 385 | LOG_DEBUG(Service_ACC, "called"); |
| 383 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 386 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 384 | rb.Push(RESULT_SUCCESS); | 387 | rb.Push(RESULT_SUCCESS); |
| 385 | rb.PushIpcInterface<IManagerForApplication>(); | 388 | rb.PushIpcInterface<IManagerForApplication>(profile_manager->GetLastOpenedUser()); |
| 386 | } | 389 | } |
| 387 | 390 | ||
| 388 | void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx) { | 391 | void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx) { |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index a967e6ef7..4df74c4f9 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -1525,14 +1525,15 @@ void InstallInterfaces(SM::ServiceManager& service_manager, | |||
| 1525 | std::make_shared<TCAP>()->InstallAsService(service_manager); | 1525 | std::make_shared<TCAP>()->InstallAsService(service_manager); |
| 1526 | } | 1526 | } |
| 1527 | 1527 | ||
| 1528 | IHomeMenuFunctions::IHomeMenuFunctions() : ServiceFramework("IHomeMenuFunctions") { | 1528 | IHomeMenuFunctions::IHomeMenuFunctions(Kernel::KernelCore& kernel) |
| 1529 | : ServiceFramework("IHomeMenuFunctions"), kernel(kernel) { | ||
| 1529 | // clang-format off | 1530 | // clang-format off |
| 1530 | static const FunctionInfo functions[] = { | 1531 | static const FunctionInfo functions[] = { |
| 1531 | {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"}, | 1532 | {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"}, |
| 1532 | {11, nullptr, "LockForeground"}, | 1533 | {11, nullptr, "LockForeground"}, |
| 1533 | {12, nullptr, "UnlockForeground"}, | 1534 | {12, nullptr, "UnlockForeground"}, |
| 1534 | {20, nullptr, "PopFromGeneralChannel"}, | 1535 | {20, nullptr, "PopFromGeneralChannel"}, |
| 1535 | {21, nullptr, "GetPopFromGeneralChannelEvent"}, | 1536 | {21, &IHomeMenuFunctions::GetPopFromGeneralChannelEvent, "GetPopFromGeneralChannelEvent"}, |
| 1536 | {30, nullptr, "GetHomeButtonWriterLockAccessor"}, | 1537 | {30, nullptr, "GetHomeButtonWriterLockAccessor"}, |
| 1537 | {31, nullptr, "GetWriterLockAccessorEx"}, | 1538 | {31, nullptr, "GetWriterLockAccessorEx"}, |
| 1538 | {100, nullptr, "PopRequestLaunchApplicationForDebug"}, | 1539 | {100, nullptr, "PopRequestLaunchApplicationForDebug"}, |
| @@ -1542,6 +1543,9 @@ IHomeMenuFunctions::IHomeMenuFunctions() : ServiceFramework("IHomeMenuFunctions" | |||
| 1542 | // clang-format on | 1543 | // clang-format on |
| 1543 | 1544 | ||
| 1544 | RegisterHandlers(functions); | 1545 | RegisterHandlers(functions); |
| 1546 | |||
| 1547 | pop_from_general_channel_event = Kernel::WritableEvent::CreateEventPair( | ||
| 1548 | kernel, "IHomeMenuFunctions:PopFromGeneralChannelEvent"); | ||
| 1545 | } | 1549 | } |
| 1546 | 1550 | ||
| 1547 | IHomeMenuFunctions::~IHomeMenuFunctions() = default; | 1551 | IHomeMenuFunctions::~IHomeMenuFunctions() = default; |
| @@ -1553,6 +1557,14 @@ void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) | |||
| 1553 | rb.Push(RESULT_SUCCESS); | 1557 | rb.Push(RESULT_SUCCESS); |
| 1554 | } | 1558 | } |
| 1555 | 1559 | ||
| 1560 | void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx) { | ||
| 1561 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 1562 | |||
| 1563 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 1564 | rb.Push(RESULT_SUCCESS); | ||
| 1565 | rb.PushCopyObjects(pop_from_general_channel_event.readable); | ||
| 1566 | } | ||
| 1567 | |||
| 1556 | IGlobalStateController::IGlobalStateController() : ServiceFramework("IGlobalStateController") { | 1568 | IGlobalStateController::IGlobalStateController() : ServiceFramework("IGlobalStateController") { |
| 1557 | // clang-format off | 1569 | // clang-format off |
| 1558 | static const FunctionInfo functions[] = { | 1570 | static const FunctionInfo functions[] = { |
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index dfa701d73..469f7f814 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h | |||
| @@ -292,11 +292,15 @@ private: | |||
| 292 | 292 | ||
| 293 | class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> { | 293 | class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> { |
| 294 | public: | 294 | public: |
| 295 | IHomeMenuFunctions(); | 295 | explicit IHomeMenuFunctions(Kernel::KernelCore& kernel); |
| 296 | ~IHomeMenuFunctions() override; | 296 | ~IHomeMenuFunctions() override; |
| 297 | 297 | ||
| 298 | private: | 298 | private: |
| 299 | void RequestToGetForeground(Kernel::HLERequestContext& ctx); | 299 | void RequestToGetForeground(Kernel::HLERequestContext& ctx); |
| 300 | void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx); | ||
| 301 | |||
| 302 | Kernel::EventPair pop_from_general_channel_event; | ||
| 303 | Kernel::KernelCore& kernel; | ||
| 300 | }; | 304 | }; |
| 301 | 305 | ||
| 302 | class IGlobalStateController final : public ServiceFramework<IGlobalStateController> { | 306 | class IGlobalStateController final : public ServiceFramework<IGlobalStateController> { |
diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cpp index e454b77d8..9df286d17 100644 --- a/src/core/hle/service/am/applet_ae.cpp +++ b/src/core/hle/service/am/applet_ae.cpp | |||
| @@ -202,7 +202,7 @@ private: | |||
| 202 | 202 | ||
| 203 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 203 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 204 | rb.Push(RESULT_SUCCESS); | 204 | rb.Push(RESULT_SUCCESS); |
| 205 | rb.PushIpcInterface<IHomeMenuFunctions>(); | 205 | rb.PushIpcInterface<IHomeMenuFunctions>(system.Kernel()); |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | void GetGlobalStateController(Kernel::HLERequestContext& ctx) { | 208 | void GetGlobalStateController(Kernel::HLERequestContext& ctx) { |
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index ff53282c9..d23c53843 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -8,6 +8,7 @@ add_library(video_core STATIC | |||
| 8 | dma_pusher.h | 8 | dma_pusher.h |
| 9 | engines/const_buffer_engine_interface.h | 9 | engines/const_buffer_engine_interface.h |
| 10 | engines/const_buffer_info.h | 10 | engines/const_buffer_info.h |
| 11 | engines/engine_interface.h | ||
| 11 | engines/engine_upload.cpp | 12 | engines/engine_upload.cpp |
| 12 | engines/engine_upload.h | 13 | engines/engine_upload.h |
| 13 | engines/fermi_2d.cpp | 14 | engines/fermi_2d.cpp |
diff --git a/src/video_core/dma_pusher.cpp b/src/video_core/dma_pusher.cpp index 16311f05e..bdc023d54 100644 --- a/src/video_core/dma_pusher.cpp +++ b/src/video_core/dma_pusher.cpp | |||
| @@ -27,6 +27,8 @@ void DmaPusher::DispatchCalls() { | |||
| 27 | 27 | ||
| 28 | dma_pushbuffer_subindex = 0; | 28 | dma_pushbuffer_subindex = 0; |
| 29 | 29 | ||
| 30 | dma_state.is_last_call = true; | ||
| 31 | |||
| 30 | while (system.IsPoweredOn()) { | 32 | while (system.IsPoweredOn()) { |
| 31 | if (!Step()) { | 33 | if (!Step()) { |
| 32 | break; | 34 | break; |
| @@ -82,9 +84,11 @@ bool DmaPusher::Step() { | |||
| 82 | index); | 84 | index); |
| 83 | CallMultiMethod(&command_header.argument, max_write); | 85 | CallMultiMethod(&command_header.argument, max_write); |
| 84 | dma_state.method_count -= max_write; | 86 | dma_state.method_count -= max_write; |
| 87 | dma_state.is_last_call = true; | ||
| 85 | index += max_write; | 88 | index += max_write; |
| 86 | continue; | 89 | continue; |
| 87 | } else { | 90 | } else { |
| 91 | dma_state.is_last_call = dma_state.method_count <= 1; | ||
| 88 | CallMethod(command_header.argument); | 92 | CallMethod(command_header.argument); |
| 89 | } | 93 | } |
| 90 | 94 | ||
| @@ -144,12 +148,22 @@ void DmaPusher::SetState(const CommandHeader& command_header) { | |||
| 144 | } | 148 | } |
| 145 | 149 | ||
| 146 | void DmaPusher::CallMethod(u32 argument) const { | 150 | void DmaPusher::CallMethod(u32 argument) const { |
| 147 | gpu.CallMethod({dma_state.method, argument, dma_state.subchannel, dma_state.method_count}); | 151 | if (dma_state.method < non_puller_methods) { |
| 152 | gpu.CallMethod({dma_state.method, argument, dma_state.subchannel, dma_state.method_count}); | ||
| 153 | } else { | ||
| 154 | subchannels[dma_state.subchannel]->CallMethod(dma_state.method, argument, | ||
| 155 | dma_state.is_last_call); | ||
| 156 | } | ||
| 148 | } | 157 | } |
| 149 | 158 | ||
| 150 | void DmaPusher::CallMultiMethod(const u32* base_start, u32 num_methods) const { | 159 | void DmaPusher::CallMultiMethod(const u32* base_start, u32 num_methods) const { |
| 151 | gpu.CallMultiMethod(dma_state.method, dma_state.subchannel, base_start, num_methods, | 160 | if (dma_state.method < non_puller_methods) { |
| 152 | dma_state.method_count); | 161 | gpu.CallMultiMethod(dma_state.method, dma_state.subchannel, base_start, num_methods, |
| 162 | dma_state.method_count); | ||
| 163 | } else { | ||
| 164 | subchannels[dma_state.subchannel]->CallMultiMethod(dma_state.method, base_start, | ||
| 165 | num_methods, dma_state.method_count); | ||
| 166 | } | ||
| 153 | } | 167 | } |
| 154 | 168 | ||
| 155 | } // namespace Tegra | 169 | } // namespace Tegra |
diff --git a/src/video_core/dma_pusher.h b/src/video_core/dma_pusher.h index 6cef71306..e8b714e94 100644 --- a/src/video_core/dma_pusher.h +++ b/src/video_core/dma_pusher.h | |||
| @@ -4,11 +4,13 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <vector> | 8 | #include <vector> |
| 8 | #include <queue> | 9 | #include <queue> |
| 9 | 10 | ||
| 10 | #include "common/bit_field.h" | 11 | #include "common/bit_field.h" |
| 11 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "video_core/engines/engine_interface.h" | ||
| 12 | 14 | ||
| 13 | namespace Core { | 15 | namespace Core { |
| 14 | class System; | 16 | class System; |
| @@ -69,7 +71,13 @@ public: | |||
| 69 | 71 | ||
| 70 | void DispatchCalls(); | 72 | void DispatchCalls(); |
| 71 | 73 | ||
| 74 | void BindSubchannel(Tegra::Engines::EngineInterface* engine, u32 subchannel_id) { | ||
| 75 | subchannels[subchannel_id] = engine; | ||
| 76 | } | ||
| 77 | |||
| 72 | private: | 78 | private: |
| 79 | static constexpr u32 non_puller_methods = 0x40; | ||
| 80 | static constexpr u32 max_subchannels = 8; | ||
| 73 | bool Step(); | 81 | bool Step(); |
| 74 | 82 | ||
| 75 | void SetState(const CommandHeader& command_header); | 83 | void SetState(const CommandHeader& command_header); |
| @@ -88,6 +96,7 @@ private: | |||
| 88 | u32 method_count; ///< Current method count | 96 | u32 method_count; ///< Current method count |
| 89 | u32 length_pending; ///< Large NI command length pending | 97 | u32 length_pending; ///< Large NI command length pending |
| 90 | bool non_incrementing; ///< Current command's NI flag | 98 | bool non_incrementing; ///< Current command's NI flag |
| 99 | bool is_last_call; | ||
| 91 | }; | 100 | }; |
| 92 | 101 | ||
| 93 | DmaState dma_state{}; | 102 | DmaState dma_state{}; |
| @@ -96,6 +105,8 @@ private: | |||
| 96 | GPUVAddr dma_mget{}; ///< main pushbuffer last read address | 105 | GPUVAddr dma_mget{}; ///< main pushbuffer last read address |
| 97 | bool ib_enable{true}; ///< IB mode enabled | 106 | bool ib_enable{true}; ///< IB mode enabled |
| 98 | 107 | ||
| 108 | std::array<Tegra::Engines::EngineInterface*, max_subchannels> subchannels{}; | ||
| 109 | |||
| 99 | GPU& gpu; | 110 | GPU& gpu; |
| 100 | Core::System& system; | 111 | Core::System& system; |
| 101 | }; | 112 | }; |
diff --git a/src/video_core/engines/engine_interface.h b/src/video_core/engines/engine_interface.h new file mode 100644 index 000000000..18a9db7e6 --- /dev/null +++ b/src/video_core/engines/engine_interface.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <type_traits> | ||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Tegra::Engines { | ||
| 11 | |||
| 12 | class EngineInterface { | ||
| 13 | public: | ||
| 14 | /// Write the value to the register identified by method. | ||
| 15 | virtual void CallMethod(u32 method, u32 method_argument, bool is_last_call) = 0; | ||
| 16 | |||
| 17 | /// Write multiple values to the register identified by method. | ||
| 18 | virtual void CallMultiMethod(u32 method, const u32* base_start, u32 amount, | ||
| 19 | u32 methods_pending) = 0; | ||
| 20 | }; | ||
| 21 | |||
| 22 | } // namespace Tegra::Engines | ||
diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp index 8a47614d2..ff10ff40d 100644 --- a/src/video_core/engines/fermi_2d.cpp +++ b/src/video_core/engines/fermi_2d.cpp | |||
| @@ -12,13 +12,13 @@ namespace Tegra::Engines { | |||
| 12 | 12 | ||
| 13 | Fermi2D::Fermi2D(VideoCore::RasterizerInterface& rasterizer) : rasterizer{rasterizer} {} | 13 | Fermi2D::Fermi2D(VideoCore::RasterizerInterface& rasterizer) : rasterizer{rasterizer} {} |
| 14 | 14 | ||
| 15 | void Fermi2D::CallMethod(const GPU::MethodCall& method_call) { | 15 | void Fermi2D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { |
| 16 | ASSERT_MSG(method_call.method < Regs::NUM_REGS, | 16 | ASSERT_MSG(method < Regs::NUM_REGS, |
| 17 | "Invalid Fermi2D register, increase the size of the Regs structure"); | 17 | "Invalid Fermi2D register, increase the size of the Regs structure"); |
| 18 | 18 | ||
| 19 | regs.reg_array[method_call.method] = method_call.argument; | 19 | regs.reg_array[method] = method_argument; |
| 20 | 20 | ||
| 21 | switch (method_call.method) { | 21 | switch (method) { |
| 22 | // Trigger the surface copy on the last register write. This is blit_src_y, but this is 64-bit, | 22 | // Trigger the surface copy on the last register write. This is blit_src_y, but this is 64-bit, |
| 23 | // so trigger on the second 32-bit write. | 23 | // so trigger on the second 32-bit write. |
| 24 | case FERMI2D_REG_INDEX(blit_src_y) + 1: { | 24 | case FERMI2D_REG_INDEX(blit_src_y) + 1: { |
| @@ -30,7 +30,7 @@ void Fermi2D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 30 | 30 | ||
| 31 | void Fermi2D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending) { | 31 | void Fermi2D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending) { |
| 32 | for (std::size_t i = 0; i < amount; i++) { | 32 | for (std::size_t i = 0; i < amount; i++) { |
| 33 | CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)}); | 33 | CallMethod(method, base_start[i], methods_pending - static_cast<u32>(i) <= 1); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 36 | 36 | ||
diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h index 939a5966d..8f37d053f 100644 --- a/src/video_core/engines/fermi_2d.h +++ b/src/video_core/engines/fermi_2d.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/math_util.h" | 12 | #include "common/math_util.h" |
| 13 | #include "video_core/engines/engine_interface.h" | ||
| 13 | #include "video_core/gpu.h" | 14 | #include "video_core/gpu.h" |
| 14 | 15 | ||
| 15 | namespace Tegra { | 16 | namespace Tegra { |
| @@ -31,16 +32,17 @@ namespace Tegra::Engines { | |||
| 31 | #define FERMI2D_REG_INDEX(field_name) \ | 32 | #define FERMI2D_REG_INDEX(field_name) \ |
| 32 | (offsetof(Tegra::Engines::Fermi2D::Regs, field_name) / sizeof(u32)) | 33 | (offsetof(Tegra::Engines::Fermi2D::Regs, field_name) / sizeof(u32)) |
| 33 | 34 | ||
| 34 | class Fermi2D final { | 35 | class Fermi2D final : public EngineInterface { |
| 35 | public: | 36 | public: |
| 36 | explicit Fermi2D(VideoCore::RasterizerInterface& rasterizer); | 37 | explicit Fermi2D(VideoCore::RasterizerInterface& rasterizer); |
| 37 | ~Fermi2D() = default; | 38 | ~Fermi2D() = default; |
| 38 | 39 | ||
| 39 | /// Write the value to the register identified by method. | 40 | /// Write the value to the register identified by method. |
| 40 | void CallMethod(const GPU::MethodCall& method_call); | 41 | void CallMethod(u32 method, u32 method_argument, bool is_last_call) override; |
| 41 | 42 | ||
| 42 | /// Write multiple values to the register identified by method. | 43 | /// Write multiple values to the register identified by method. |
| 43 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending); | 44 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, |
| 45 | u32 methods_pending) override; | ||
| 44 | 46 | ||
| 45 | enum class Origin : u32 { | 47 | enum class Origin : u32 { |
| 46 | Center = 0, | 48 | Center = 0, |
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp index 00a12175f..f6237fc6a 100644 --- a/src/video_core/engines/kepler_compute.cpp +++ b/src/video_core/engines/kepler_compute.cpp | |||
| @@ -24,20 +24,19 @@ KeplerCompute::KeplerCompute(Core::System& system, VideoCore::RasterizerInterfac | |||
| 24 | 24 | ||
| 25 | KeplerCompute::~KeplerCompute() = default; | 25 | KeplerCompute::~KeplerCompute() = default; |
| 26 | 26 | ||
| 27 | void KeplerCompute::CallMethod(const GPU::MethodCall& method_call) { | 27 | void KeplerCompute::CallMethod(u32 method, u32 method_argument, bool is_last_call) { |
| 28 | ASSERT_MSG(method_call.method < Regs::NUM_REGS, | 28 | ASSERT_MSG(method < Regs::NUM_REGS, |
| 29 | "Invalid KeplerCompute register, increase the size of the Regs structure"); | 29 | "Invalid KeplerCompute register, increase the size of the Regs structure"); |
| 30 | 30 | ||
| 31 | regs.reg_array[method_call.method] = method_call.argument; | 31 | regs.reg_array[method] = method_argument; |
| 32 | 32 | ||
| 33 | switch (method_call.method) { | 33 | switch (method) { |
| 34 | case KEPLER_COMPUTE_REG_INDEX(exec_upload): { | 34 | case KEPLER_COMPUTE_REG_INDEX(exec_upload): { |
| 35 | upload_state.ProcessExec(regs.exec_upload.linear != 0); | 35 | upload_state.ProcessExec(regs.exec_upload.linear != 0); |
| 36 | break; | 36 | break; |
| 37 | } | 37 | } |
| 38 | case KEPLER_COMPUTE_REG_INDEX(data_upload): { | 38 | case KEPLER_COMPUTE_REG_INDEX(data_upload): { |
| 39 | const bool is_last_call = method_call.IsLastCall(); | 39 | upload_state.ProcessData(method_argument, is_last_call); |
| 40 | upload_state.ProcessData(method_call.argument, is_last_call); | ||
| 41 | if (is_last_call) { | 40 | if (is_last_call) { |
| 42 | system.GPU().Maxwell3D().OnMemoryWrite(); | 41 | system.GPU().Maxwell3D().OnMemoryWrite(); |
| 43 | } | 42 | } |
| @@ -54,7 +53,7 @@ void KeplerCompute::CallMethod(const GPU::MethodCall& method_call) { | |||
| 54 | void KeplerCompute::CallMultiMethod(u32 method, const u32* base_start, u32 amount, | 53 | void KeplerCompute::CallMultiMethod(u32 method, const u32* base_start, u32 amount, |
| 55 | u32 methods_pending) { | 54 | u32 methods_pending) { |
| 56 | for (std::size_t i = 0; i < amount; i++) { | 55 | for (std::size_t i = 0; i < amount; i++) { |
| 57 | CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)}); | 56 | CallMethod(method, base_start[i], methods_pending - static_cast<u32>(i) <= 1); |
| 58 | } | 57 | } |
| 59 | } | 58 | } |
| 60 | 59 | ||
diff --git a/src/video_core/engines/kepler_compute.h b/src/video_core/engines/kepler_compute.h index fe55fdfd0..18ceedfaf 100644 --- a/src/video_core/engines/kepler_compute.h +++ b/src/video_core/engines/kepler_compute.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "common/common_funcs.h" | 11 | #include "common/common_funcs.h" |
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "video_core/engines/const_buffer_engine_interface.h" | 13 | #include "video_core/engines/const_buffer_engine_interface.h" |
| 14 | #include "video_core/engines/engine_interface.h" | ||
| 14 | #include "video_core/engines/engine_upload.h" | 15 | #include "video_core/engines/engine_upload.h" |
| 15 | #include "video_core/engines/shader_type.h" | 16 | #include "video_core/engines/shader_type.h" |
| 16 | #include "video_core/gpu.h" | 17 | #include "video_core/gpu.h" |
| @@ -39,7 +40,7 @@ namespace Tegra::Engines { | |||
| 39 | #define KEPLER_COMPUTE_REG_INDEX(field_name) \ | 40 | #define KEPLER_COMPUTE_REG_INDEX(field_name) \ |
| 40 | (offsetof(Tegra::Engines::KeplerCompute::Regs, field_name) / sizeof(u32)) | 41 | (offsetof(Tegra::Engines::KeplerCompute::Regs, field_name) / sizeof(u32)) |
| 41 | 42 | ||
| 42 | class KeplerCompute final : public ConstBufferEngineInterface { | 43 | class KeplerCompute final : public ConstBufferEngineInterface, public EngineInterface { |
| 43 | public: | 44 | public: |
| 44 | explicit KeplerCompute(Core::System& system, VideoCore::RasterizerInterface& rasterizer, | 45 | explicit KeplerCompute(Core::System& system, VideoCore::RasterizerInterface& rasterizer, |
| 45 | MemoryManager& memory_manager); | 46 | MemoryManager& memory_manager); |
| @@ -200,10 +201,11 @@ public: | |||
| 200 | "KeplerCompute LaunchParams has wrong size"); | 201 | "KeplerCompute LaunchParams has wrong size"); |
| 201 | 202 | ||
| 202 | /// Write the value to the register identified by method. | 203 | /// Write the value to the register identified by method. |
| 203 | void CallMethod(const GPU::MethodCall& method_call); | 204 | void CallMethod(u32 method, u32 method_argument, bool is_last_call) override; |
| 204 | 205 | ||
| 205 | /// Write multiple values to the register identified by method. | 206 | /// Write multiple values to the register identified by method. |
| 206 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending); | 207 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, |
| 208 | u32 methods_pending) override; | ||
| 207 | 209 | ||
| 208 | Texture::FullTextureInfo GetTexture(std::size_t offset) const; | 210 | Texture::FullTextureInfo GetTexture(std::size_t offset) const; |
| 209 | 211 | ||
diff --git a/src/video_core/engines/kepler_memory.cpp b/src/video_core/engines/kepler_memory.cpp index 586ff15dc..dc71b2eec 100644 --- a/src/video_core/engines/kepler_memory.cpp +++ b/src/video_core/engines/kepler_memory.cpp | |||
| @@ -19,20 +19,19 @@ KeplerMemory::KeplerMemory(Core::System& system, MemoryManager& memory_manager) | |||
| 19 | 19 | ||
| 20 | KeplerMemory::~KeplerMemory() = default; | 20 | KeplerMemory::~KeplerMemory() = default; |
| 21 | 21 | ||
| 22 | void KeplerMemory::CallMethod(const GPU::MethodCall& method_call) { | 22 | void KeplerMemory::CallMethod(u32 method, u32 method_argument, bool is_last_call) { |
| 23 | ASSERT_MSG(method_call.method < Regs::NUM_REGS, | 23 | ASSERT_MSG(method < Regs::NUM_REGS, |
| 24 | "Invalid KeplerMemory register, increase the size of the Regs structure"); | 24 | "Invalid KeplerMemory register, increase the size of the Regs structure"); |
| 25 | 25 | ||
| 26 | regs.reg_array[method_call.method] = method_call.argument; | 26 | regs.reg_array[method] = method_argument; |
| 27 | 27 | ||
| 28 | switch (method_call.method) { | 28 | switch (method) { |
| 29 | case KEPLERMEMORY_REG_INDEX(exec): { | 29 | case KEPLERMEMORY_REG_INDEX(exec): { |
| 30 | upload_state.ProcessExec(regs.exec.linear != 0); | 30 | upload_state.ProcessExec(regs.exec.linear != 0); |
| 31 | break; | 31 | break; |
| 32 | } | 32 | } |
| 33 | case KEPLERMEMORY_REG_INDEX(data): { | 33 | case KEPLERMEMORY_REG_INDEX(data): { |
| 34 | const bool is_last_call = method_call.IsLastCall(); | 34 | upload_state.ProcessData(method_argument, is_last_call); |
| 35 | upload_state.ProcessData(method_call.argument, is_last_call); | ||
| 36 | if (is_last_call) { | 35 | if (is_last_call) { |
| 37 | system.GPU().Maxwell3D().OnMemoryWrite(); | 36 | system.GPU().Maxwell3D().OnMemoryWrite(); |
| 38 | } | 37 | } |
| @@ -44,7 +43,7 @@ void KeplerMemory::CallMethod(const GPU::MethodCall& method_call) { | |||
| 44 | void KeplerMemory::CallMultiMethod(u32 method, const u32* base_start, u32 amount, | 43 | void KeplerMemory::CallMultiMethod(u32 method, const u32* base_start, u32 amount, |
| 45 | u32 methods_pending) { | 44 | u32 methods_pending) { |
| 46 | for (std::size_t i = 0; i < amount; i++) { | 45 | for (std::size_t i = 0; i < amount; i++) { |
| 47 | CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)}); | 46 | CallMethod(method, base_start[i], methods_pending - static_cast<u32>(i) <= 1); |
| 48 | } | 47 | } |
| 49 | } | 48 | } |
| 50 | 49 | ||
diff --git a/src/video_core/engines/kepler_memory.h b/src/video_core/engines/kepler_memory.h index bb26fb030..5b7f71a00 100644 --- a/src/video_core/engines/kepler_memory.h +++ b/src/video_core/engines/kepler_memory.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/bit_field.h" | 10 | #include "common/bit_field.h" |
| 11 | #include "common/common_funcs.h" | 11 | #include "common/common_funcs.h" |
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "video_core/engines/engine_interface.h" | ||
| 13 | #include "video_core/engines/engine_upload.h" | 14 | #include "video_core/engines/engine_upload.h" |
| 14 | #include "video_core/gpu.h" | 15 | #include "video_core/gpu.h" |
| 15 | 16 | ||
| @@ -32,16 +33,17 @@ namespace Tegra::Engines { | |||
| 32 | #define KEPLERMEMORY_REG_INDEX(field_name) \ | 33 | #define KEPLERMEMORY_REG_INDEX(field_name) \ |
| 33 | (offsetof(Tegra::Engines::KeplerMemory::Regs, field_name) / sizeof(u32)) | 34 | (offsetof(Tegra::Engines::KeplerMemory::Regs, field_name) / sizeof(u32)) |
| 34 | 35 | ||
| 35 | class KeplerMemory final { | 36 | class KeplerMemory final : public EngineInterface { |
| 36 | public: | 37 | public: |
| 37 | KeplerMemory(Core::System& system, MemoryManager& memory_manager); | 38 | KeplerMemory(Core::System& system, MemoryManager& memory_manager); |
| 38 | ~KeplerMemory(); | 39 | ~KeplerMemory(); |
| 39 | 40 | ||
| 40 | /// Write the value to the register identified by method. | 41 | /// Write the value to the register identified by method. |
| 41 | void CallMethod(const GPU::MethodCall& method_call); | 42 | void CallMethod(u32 method, u32 method_argument, bool is_last_call) override; |
| 42 | 43 | ||
| 43 | /// Write multiple values to the register identified by method. | 44 | /// Write multiple values to the register identified by method. |
| 44 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending); | 45 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, |
| 46 | u32 methods_pending) override; | ||
| 45 | 47 | ||
| 46 | struct Regs { | 48 | struct Regs { |
| 47 | static constexpr size_t NUM_REGS = 0x7F; | 49 | static constexpr size_t NUM_REGS = 0x7F; |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 7db055ea0..33936e209 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -125,12 +125,10 @@ void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u3 | |||
| 125 | } | 125 | } |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | 128 | void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { |
| 129 | const u32 method = method_call.method; | ||
| 130 | |||
| 131 | if (method == cb_data_state.current) { | 129 | if (method == cb_data_state.current) { |
| 132 | regs.reg_array[method] = method_call.argument; | 130 | regs.reg_array[method] = method_argument; |
| 133 | ProcessCBData(method_call.argument); | 131 | ProcessCBData(method_argument); |
| 134 | return; | 132 | return; |
| 135 | } else if (cb_data_state.current != null_cb_data) { | 133 | } else if (cb_data_state.current != null_cb_data) { |
| 136 | FinishCBData(); | 134 | FinishCBData(); |
| @@ -153,10 +151,10 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 153 | executing_macro = method; | 151 | executing_macro = method; |
| 154 | } | 152 | } |
| 155 | 153 | ||
| 156 | macro_params.push_back(method_call.argument); | 154 | macro_params.push_back(method_argument); |
| 157 | 155 | ||
| 158 | // Call the macro when there are no more parameters in the command buffer | 156 | // Call the macro when there are no more parameters in the command buffer |
| 159 | if (method_call.IsLastCall()) { | 157 | if (is_last_call) { |
| 160 | CallMacroMethod(executing_macro, macro_params.size(), macro_params.data()); | 158 | CallMacroMethod(executing_macro, macro_params.size(), macro_params.data()); |
| 161 | macro_params.clear(); | 159 | macro_params.clear(); |
| 162 | } | 160 | } |
| @@ -166,7 +164,7 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 166 | ASSERT_MSG(method < Regs::NUM_REGS, | 164 | ASSERT_MSG(method < Regs::NUM_REGS, |
| 167 | "Invalid Maxwell3D register, increase the size of the Regs structure"); | 165 | "Invalid Maxwell3D register, increase the size of the Regs structure"); |
| 168 | 166 | ||
| 169 | u32 arg = method_call.argument; | 167 | u32 arg = method_argument; |
| 170 | // Keep track of the register value in shadow_state when requested. | 168 | // Keep track of the register value in shadow_state when requested. |
| 171 | if (shadow_state.shadow_ram_control == Regs::ShadowRamControl::Track || | 169 | if (shadow_state.shadow_ram_control == Regs::ShadowRamControl::Track || |
| 172 | shadow_state.shadow_ram_control == Regs::ShadowRamControl::TrackWithFilter) { | 170 | shadow_state.shadow_ram_control == Regs::ShadowRamControl::TrackWithFilter) { |
| @@ -189,7 +187,7 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 189 | break; | 187 | break; |
| 190 | } | 188 | } |
| 191 | case MAXWELL3D_REG_INDEX(shadow_ram_control): { | 189 | case MAXWELL3D_REG_INDEX(shadow_ram_control): { |
| 192 | shadow_state.shadow_ram_control = static_cast<Regs::ShadowRamControl>(method_call.argument); | 190 | shadow_state.shadow_ram_control = static_cast<Regs::ShadowRamControl>(method_argument); |
| 193 | break; | 191 | break; |
| 194 | } | 192 | } |
| 195 | case MAXWELL3D_REG_INDEX(macros.data): { | 193 | case MAXWELL3D_REG_INDEX(macros.data): { |
| @@ -272,7 +270,6 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 272 | break; | 270 | break; |
| 273 | } | 271 | } |
| 274 | case MAXWELL3D_REG_INDEX(data_upload): { | 272 | case MAXWELL3D_REG_INDEX(data_upload): { |
| 275 | const bool is_last_call = method_call.IsLastCall(); | ||
| 276 | upload_state.ProcessData(arg, is_last_call); | 273 | upload_state.ProcessData(arg, is_last_call); |
| 277 | if (is_last_call) { | 274 | if (is_last_call) { |
| 278 | OnMemoryWrite(); | 275 | OnMemoryWrite(); |
| @@ -330,7 +327,7 @@ void Maxwell3D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, | |||
| 330 | } | 327 | } |
| 331 | default: { | 328 | default: { |
| 332 | for (std::size_t i = 0; i < amount; i++) { | 329 | for (std::size_t i = 0; i < amount; i++) { |
| 333 | CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)}); | 330 | CallMethod(method, base_start[i], methods_pending - static_cast<u32>(i) <= 1); |
| 334 | } | 331 | } |
| 335 | } | 332 | } |
| 336 | } | 333 | } |
| @@ -360,16 +357,15 @@ void Maxwell3D::StepInstance(const MMEDrawMode expected_mode, const u32 count) { | |||
| 360 | StepInstance(expected_mode, count); | 357 | StepInstance(expected_mode, count); |
| 361 | } | 358 | } |
| 362 | 359 | ||
| 363 | void Maxwell3D::CallMethodFromMME(const GPU::MethodCall& method_call) { | 360 | void Maxwell3D::CallMethodFromMME(u32 method, u32 method_argument) { |
| 364 | const u32 method = method_call.method; | ||
| 365 | if (mme_inline[method]) { | 361 | if (mme_inline[method]) { |
| 366 | regs.reg_array[method] = method_call.argument; | 362 | regs.reg_array[method] = method_argument; |
| 367 | if (method == MAXWELL3D_REG_INDEX(vertex_buffer.count) || | 363 | if (method == MAXWELL3D_REG_INDEX(vertex_buffer.count) || |
| 368 | method == MAXWELL3D_REG_INDEX(index_array.count)) { | 364 | method == MAXWELL3D_REG_INDEX(index_array.count)) { |
| 369 | const MMEDrawMode expected_mode = method == MAXWELL3D_REG_INDEX(vertex_buffer.count) | 365 | const MMEDrawMode expected_mode = method == MAXWELL3D_REG_INDEX(vertex_buffer.count) |
| 370 | ? MMEDrawMode::Array | 366 | ? MMEDrawMode::Array |
| 371 | : MMEDrawMode::Indexed; | 367 | : MMEDrawMode::Indexed; |
| 372 | StepInstance(expected_mode, method_call.argument); | 368 | StepInstance(expected_mode, method_argument); |
| 373 | } else if (method == MAXWELL3D_REG_INDEX(draw.vertex_begin_gl)) { | 369 | } else if (method == MAXWELL3D_REG_INDEX(draw.vertex_begin_gl)) { |
| 374 | mme_draw.instance_mode = | 370 | mme_draw.instance_mode = |
| 375 | (regs.draw.instance_next != 0) || (regs.draw.instance_cont != 0); | 371 | (regs.draw.instance_next != 0) || (regs.draw.instance_cont != 0); |
| @@ -381,7 +377,7 @@ void Maxwell3D::CallMethodFromMME(const GPU::MethodCall& method_call) { | |||
| 381 | if (mme_draw.current_mode != MMEDrawMode::Undefined) { | 377 | if (mme_draw.current_mode != MMEDrawMode::Undefined) { |
| 382 | FlushMMEInlineDraw(); | 378 | FlushMMEInlineDraw(); |
| 383 | } | 379 | } |
| 384 | CallMethod(method_call); | 380 | CallMethod(method, method_argument, true); |
| 385 | } | 381 | } |
| 386 | } | 382 | } |
| 387 | 383 | ||
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 864924ff3..1a5df05ce 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "common/math_util.h" | 19 | #include "common/math_util.h" |
| 20 | #include "video_core/engines/const_buffer_engine_interface.h" | 20 | #include "video_core/engines/const_buffer_engine_interface.h" |
| 21 | #include "video_core/engines/const_buffer_info.h" | 21 | #include "video_core/engines/const_buffer_info.h" |
| 22 | #include "video_core/engines/engine_interface.h" | ||
| 22 | #include "video_core/engines/engine_upload.h" | 23 | #include "video_core/engines/engine_upload.h" |
| 23 | #include "video_core/engines/shader_type.h" | 24 | #include "video_core/engines/shader_type.h" |
| 24 | #include "video_core/gpu.h" | 25 | #include "video_core/gpu.h" |
| @@ -48,7 +49,7 @@ namespace Tegra::Engines { | |||
| 48 | #define MAXWELL3D_REG_INDEX(field_name) \ | 49 | #define MAXWELL3D_REG_INDEX(field_name) \ |
| 49 | (offsetof(Tegra::Engines::Maxwell3D::Regs, field_name) / sizeof(u32)) | 50 | (offsetof(Tegra::Engines::Maxwell3D::Regs, field_name) / sizeof(u32)) |
| 50 | 51 | ||
| 51 | class Maxwell3D final : public ConstBufferEngineInterface { | 52 | class Maxwell3D final : public ConstBufferEngineInterface, public EngineInterface { |
| 52 | public: | 53 | public: |
| 53 | explicit Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer, | 54 | explicit Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer, |
| 54 | MemoryManager& memory_manager); | 55 | MemoryManager& memory_manager); |
| @@ -1360,13 +1361,14 @@ public: | |||
| 1360 | u32 GetRegisterValue(u32 method) const; | 1361 | u32 GetRegisterValue(u32 method) const; |
| 1361 | 1362 | ||
| 1362 | /// Write the value to the register identified by method. | 1363 | /// Write the value to the register identified by method. |
| 1363 | void CallMethod(const GPU::MethodCall& method_call); | 1364 | void CallMethod(u32 method, u32 method_argument, bool is_last_call) override; |
| 1364 | 1365 | ||
| 1365 | /// Write multiple values to the register identified by method. | 1366 | /// Write multiple values to the register identified by method. |
| 1366 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending); | 1367 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, |
| 1368 | u32 methods_pending) override; | ||
| 1367 | 1369 | ||
| 1368 | /// Write the value to the register identified by method. | 1370 | /// Write the value to the register identified by method. |
| 1369 | void CallMethodFromMME(const GPU::MethodCall& method_call); | 1371 | void CallMethodFromMME(u32 method, u32 method_argument); |
| 1370 | 1372 | ||
| 1371 | void FlushMMEInlineDraw(); | 1373 | void FlushMMEInlineDraw(); |
| 1372 | 1374 | ||
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index 6630005b0..01d7df405 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp | |||
| @@ -17,16 +17,16 @@ namespace Tegra::Engines { | |||
| 17 | MaxwellDMA::MaxwellDMA(Core::System& system, MemoryManager& memory_manager) | 17 | MaxwellDMA::MaxwellDMA(Core::System& system, MemoryManager& memory_manager) |
| 18 | : system{system}, memory_manager{memory_manager} {} | 18 | : system{system}, memory_manager{memory_manager} {} |
| 19 | 19 | ||
| 20 | void MaxwellDMA::CallMethod(const GPU::MethodCall& method_call) { | 20 | void MaxwellDMA::CallMethod(u32 method, u32 method_argument, bool is_last_call) { |
| 21 | ASSERT_MSG(method_call.method < Regs::NUM_REGS, | 21 | ASSERT_MSG(method < Regs::NUM_REGS, |
| 22 | "Invalid MaxwellDMA register, increase the size of the Regs structure"); | 22 | "Invalid MaxwellDMA register, increase the size of the Regs structure"); |
| 23 | 23 | ||
| 24 | regs.reg_array[method_call.method] = method_call.argument; | 24 | regs.reg_array[method] = method_argument; |
| 25 | 25 | ||
| 26 | #define MAXWELLDMA_REG_INDEX(field_name) \ | 26 | #define MAXWELLDMA_REG_INDEX(field_name) \ |
| 27 | (offsetof(Tegra::Engines::MaxwellDMA::Regs, field_name) / sizeof(u32)) | 27 | (offsetof(Tegra::Engines::MaxwellDMA::Regs, field_name) / sizeof(u32)) |
| 28 | 28 | ||
| 29 | switch (method_call.method) { | 29 | switch (method) { |
| 30 | case MAXWELLDMA_REG_INDEX(exec): { | 30 | case MAXWELLDMA_REG_INDEX(exec): { |
| 31 | HandleCopy(); | 31 | HandleCopy(); |
| 32 | break; | 32 | break; |
| @@ -39,7 +39,7 @@ void MaxwellDMA::CallMethod(const GPU::MethodCall& method_call) { | |||
| 39 | void MaxwellDMA::CallMultiMethod(u32 method, const u32* base_start, u32 amount, | 39 | void MaxwellDMA::CallMultiMethod(u32 method, const u32* base_start, u32 amount, |
| 40 | u32 methods_pending) { | 40 | u32 methods_pending) { |
| 41 | for (std::size_t i = 0; i < amount; i++) { | 41 | for (std::size_t i = 0; i < amount; i++) { |
| 42 | CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)}); | 42 | CallMethod(method, base_start[i], methods_pending - static_cast<u32>(i) <= 1); |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| @@ -90,7 +90,47 @@ void MaxwellDMA::HandleCopy() { | |||
| 90 | ASSERT(regs.exec.enable_2d == 1); | 90 | ASSERT(regs.exec.enable_2d == 1); |
| 91 | 91 | ||
| 92 | if (regs.exec.is_dst_linear && !regs.exec.is_src_linear) { | 92 | if (regs.exec.is_dst_linear && !regs.exec.is_src_linear) { |
| 93 | |||
| 93 | ASSERT(regs.src_params.BlockDepth() == 0); | 94 | ASSERT(regs.src_params.BlockDepth() == 0); |
| 95 | // Optimized path for micro copies. | ||
| 96 | if (regs.dst_pitch * regs.y_count < Texture::GetGOBSize() && regs.dst_pitch <= 64) { | ||
| 97 | const u32 bytes_per_pixel = regs.dst_pitch / regs.x_count; | ||
| 98 | const std::size_t src_size = Texture::GetGOBSize(); | ||
| 99 | const std::size_t dst_size = regs.dst_pitch * regs.y_count; | ||
| 100 | u32 pos_x = regs.src_params.pos_x; | ||
| 101 | u32 pos_y = regs.src_params.pos_y; | ||
| 102 | const u64 offset = | ||
| 103 | Texture::GetGOBOffset(regs.src_params.size_x, regs.src_params.size_y, pos_x, pos_y, | ||
| 104 | regs.src_params.BlockDepth(), bytes_per_pixel); | ||
| 105 | const u32 x_in_gob = 64 / bytes_per_pixel; | ||
| 106 | pos_x = pos_x % x_in_gob; | ||
| 107 | pos_y = pos_y % 8; | ||
| 108 | |||
| 109 | if (read_buffer.size() < src_size) { | ||
| 110 | read_buffer.resize(src_size); | ||
| 111 | } | ||
| 112 | |||
| 113 | if (write_buffer.size() < dst_size) { | ||
| 114 | write_buffer.resize(dst_size); | ||
| 115 | } | ||
| 116 | |||
| 117 | if (Settings::IsGPULevelExtreme()) { | ||
| 118 | memory_manager.ReadBlock(source + offset, read_buffer.data(), src_size); | ||
| 119 | memory_manager.ReadBlock(dest, write_buffer.data(), dst_size); | ||
| 120 | } else { | ||
| 121 | memory_manager.ReadBlockUnsafe(source + offset, read_buffer.data(), src_size); | ||
| 122 | memory_manager.ReadBlockUnsafe(dest, write_buffer.data(), dst_size); | ||
| 123 | } | ||
| 124 | |||
| 125 | Texture::UnswizzleSubrect(regs.x_count, regs.y_count, regs.dst_pitch, | ||
| 126 | regs.src_params.size_x, bytes_per_pixel, read_buffer.data(), | ||
| 127 | write_buffer.data(), regs.src_params.BlockHeight(), pos_x, | ||
| 128 | pos_y); | ||
| 129 | |||
| 130 | memory_manager.WriteBlock(dest, write_buffer.data(), dst_size); | ||
| 131 | |||
| 132 | return; | ||
| 133 | } | ||
| 94 | // If the input is tiled and the output is linear, deswizzle the input and copy it over. | 134 | // If the input is tiled and the output is linear, deswizzle the input and copy it over. |
| 95 | const u32 bytes_per_pixel = regs.dst_pitch / regs.x_count; | 135 | const u32 bytes_per_pixel = regs.dst_pitch / regs.x_count; |
| 96 | const std::size_t src_size = Texture::CalculateSize( | 136 | const std::size_t src_size = Texture::CalculateSize( |
diff --git a/src/video_core/engines/maxwell_dma.h b/src/video_core/engines/maxwell_dma.h index c43ed8194..502dd8509 100644 --- a/src/video_core/engines/maxwell_dma.h +++ b/src/video_core/engines/maxwell_dma.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/bit_field.h" | 10 | #include "common/bit_field.h" |
| 11 | #include "common/common_funcs.h" | 11 | #include "common/common_funcs.h" |
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "video_core/engines/engine_interface.h" | ||
| 13 | #include "video_core/gpu.h" | 14 | #include "video_core/gpu.h" |
| 14 | 15 | ||
| 15 | namespace Core { | 16 | namespace Core { |
| @@ -27,16 +28,17 @@ namespace Tegra::Engines { | |||
| 27 | * https://github.com/envytools/envytools/blob/master/rnndb/fifo/gk104_copy.xml | 28 | * https://github.com/envytools/envytools/blob/master/rnndb/fifo/gk104_copy.xml |
| 28 | */ | 29 | */ |
| 29 | 30 | ||
| 30 | class MaxwellDMA final { | 31 | class MaxwellDMA final : public EngineInterface { |
| 31 | public: | 32 | public: |
| 32 | explicit MaxwellDMA(Core::System& system, MemoryManager& memory_manager); | 33 | explicit MaxwellDMA(Core::System& system, MemoryManager& memory_manager); |
| 33 | ~MaxwellDMA() = default; | 34 | ~MaxwellDMA() = default; |
| 34 | 35 | ||
| 35 | /// Write the value to the register identified by method. | 36 | /// Write the value to the register identified by method. |
| 36 | void CallMethod(const GPU::MethodCall& method_call); | 37 | void CallMethod(u32 method, u32 method_argument, bool is_last_call) override; |
| 37 | 38 | ||
| 38 | /// Write multiple values to the register identified by method. | 39 | /// Write multiple values to the register identified by method. |
| 39 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending); | 40 | void CallMultiMethod(u32 method, const u32* base_start, u32 amount, |
| 41 | u32 methods_pending) override; | ||
| 40 | 42 | ||
| 41 | struct Regs { | 43 | struct Regs { |
| 42 | static constexpr std::size_t NUM_REGS = 0x1D6; | 44 | static constexpr std::size_t NUM_REGS = 0x1D6; |
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index b87fd873d..8eb017f65 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -299,19 +299,21 @@ void GPU::CallEngineMethod(const MethodCall& method_call) { | |||
| 299 | 299 | ||
| 300 | switch (engine) { | 300 | switch (engine) { |
| 301 | case EngineID::FERMI_TWOD_A: | 301 | case EngineID::FERMI_TWOD_A: |
| 302 | fermi_2d->CallMethod(method_call); | 302 | fermi_2d->CallMethod(method_call.method, method_call.argument, method_call.IsLastCall()); |
| 303 | break; | 303 | break; |
| 304 | case EngineID::MAXWELL_B: | 304 | case EngineID::MAXWELL_B: |
| 305 | maxwell_3d->CallMethod(method_call); | 305 | maxwell_3d->CallMethod(method_call.method, method_call.argument, method_call.IsLastCall()); |
| 306 | break; | 306 | break; |
| 307 | case EngineID::KEPLER_COMPUTE_B: | 307 | case EngineID::KEPLER_COMPUTE_B: |
| 308 | kepler_compute->CallMethod(method_call); | 308 | kepler_compute->CallMethod(method_call.method, method_call.argument, |
| 309 | method_call.IsLastCall()); | ||
| 309 | break; | 310 | break; |
| 310 | case EngineID::MAXWELL_DMA_COPY_A: | 311 | case EngineID::MAXWELL_DMA_COPY_A: |
| 311 | maxwell_dma->CallMethod(method_call); | 312 | maxwell_dma->CallMethod(method_call.method, method_call.argument, method_call.IsLastCall()); |
| 312 | break; | 313 | break; |
| 313 | case EngineID::KEPLER_INLINE_TO_MEMORY_B: | 314 | case EngineID::KEPLER_INLINE_TO_MEMORY_B: |
| 314 | kepler_memory->CallMethod(method_call); | 315 | kepler_memory->CallMethod(method_call.method, method_call.argument, |
| 316 | method_call.IsLastCall()); | ||
| 315 | break; | 317 | break; |
| 316 | default: | 318 | default: |
| 317 | UNIMPLEMENTED_MSG("Unimplemented engine"); | 319 | UNIMPLEMENTED_MSG("Unimplemented engine"); |
| @@ -347,7 +349,27 @@ void GPU::ProcessBindMethod(const MethodCall& method_call) { | |||
| 347 | // Bind the current subchannel to the desired engine id. | 349 | // Bind the current subchannel to the desired engine id. |
| 348 | LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", method_call.subchannel, | 350 | LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", method_call.subchannel, |
| 349 | method_call.argument); | 351 | method_call.argument); |
| 350 | bound_engines[method_call.subchannel] = static_cast<EngineID>(method_call.argument); | 352 | const auto engine_id = static_cast<EngineID>(method_call.argument); |
| 353 | bound_engines[method_call.subchannel] = static_cast<EngineID>(engine_id); | ||
| 354 | switch (engine_id) { | ||
| 355 | case EngineID::FERMI_TWOD_A: | ||
| 356 | dma_pusher->BindSubchannel(fermi_2d.get(), method_call.subchannel); | ||
| 357 | break; | ||
| 358 | case EngineID::MAXWELL_B: | ||
| 359 | dma_pusher->BindSubchannel(maxwell_3d.get(), method_call.subchannel); | ||
| 360 | break; | ||
| 361 | case EngineID::KEPLER_COMPUTE_B: | ||
| 362 | dma_pusher->BindSubchannel(kepler_compute.get(), method_call.subchannel); | ||
| 363 | break; | ||
| 364 | case EngineID::MAXWELL_DMA_COPY_A: | ||
| 365 | dma_pusher->BindSubchannel(maxwell_dma.get(), method_call.subchannel); | ||
| 366 | break; | ||
| 367 | case EngineID::KEPLER_INLINE_TO_MEMORY_B: | ||
| 368 | dma_pusher->BindSubchannel(kepler_memory.get(), method_call.subchannel); | ||
| 369 | break; | ||
| 370 | default: | ||
| 371 | UNIMPLEMENTED_MSG("Unimplemented engine {:04X}", static_cast<u32>(engine_id)); | ||
| 372 | } | ||
| 351 | } | 373 | } |
| 352 | 374 | ||
| 353 | void GPU::ProcessSemaphoreTriggerMethod() { | 375 | void GPU::ProcessSemaphoreTriggerMethod() { |
diff --git a/src/video_core/macro_interpreter.cpp b/src/video_core/macro_interpreter.cpp index 42031d80a..947364928 100644 --- a/src/video_core/macro_interpreter.cpp +++ b/src/video_core/macro_interpreter.cpp | |||
| @@ -328,7 +328,7 @@ void MacroInterpreter::SetMethodAddress(u32 address) { | |||
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | void MacroInterpreter::Send(u32 value) { | 330 | void MacroInterpreter::Send(u32 value) { |
| 331 | maxwell3d.CallMethodFromMME({method_address.address, value}); | 331 | maxwell3d.CallMethodFromMME(method_address.address, value); |
| 332 | // Increment the method address by the method increment. | 332 | // Increment the method address by the method increment. |
| 333 | method_address.address.Assign(method_address.address.Value() + | 333 | method_address.address.Assign(method_address.address.Value() + |
| 334 | method_address.increment.Value()); | 334 | method_address.increment.Value()); |
diff --git a/src/video_core/renderer_vulkan/vk_device.cpp b/src/video_core/renderer_vulkan/vk_device.cpp index 0e4bbca97..09ddfa59c 100644 --- a/src/video_core/renderer_vulkan/vk_device.cpp +++ b/src/video_core/renderer_vulkan/vk_device.cpp | |||
| @@ -293,6 +293,17 @@ bool VKDevice::Create() { | |||
| 293 | LOG_INFO(Render_Vulkan, "Device doesn't support transform feedbacks"); | 293 | LOG_INFO(Render_Vulkan, "Device doesn't support transform feedbacks"); |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | VkPhysicalDeviceCustomBorderColorFeaturesEXT custom_border; | ||
| 297 | if (ext_custom_border_color) { | ||
| 298 | custom_border.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT; | ||
| 299 | custom_border.pNext = nullptr; | ||
| 300 | custom_border.customBorderColors = VK_TRUE; | ||
| 301 | custom_border.customBorderColorWithoutFormat = VK_TRUE; | ||
| 302 | SetNext(next, custom_border); | ||
| 303 | } else { | ||
| 304 | LOG_INFO(Render_Vulkan, "Device doesn't support custom border colors"); | ||
| 305 | } | ||
| 306 | |||
| 296 | if (!ext_depth_range_unrestricted) { | 307 | if (!ext_depth_range_unrestricted) { |
| 297 | LOG_INFO(Render_Vulkan, "Device doesn't support depth range unrestricted"); | 308 | LOG_INFO(Render_Vulkan, "Device doesn't support depth range unrestricted"); |
| 298 | } | 309 | } |
| @@ -520,6 +531,7 @@ std::vector<const char*> VKDevice::LoadExtensions() { | |||
| 520 | bool has_khr_shader_float16_int8{}; | 531 | bool has_khr_shader_float16_int8{}; |
| 521 | bool has_ext_subgroup_size_control{}; | 532 | bool has_ext_subgroup_size_control{}; |
| 522 | bool has_ext_transform_feedback{}; | 533 | bool has_ext_transform_feedback{}; |
| 534 | bool has_ext_custom_border_color{}; | ||
| 523 | for (const auto& extension : physical.EnumerateDeviceExtensionProperties()) { | 535 | for (const auto& extension : physical.EnumerateDeviceExtensionProperties()) { |
| 524 | Test(extension, khr_uniform_buffer_standard_layout, | 536 | Test(extension, khr_uniform_buffer_standard_layout, |
| 525 | VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, true); | 537 | VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, true); |
| @@ -534,6 +546,8 @@ std::vector<const char*> VKDevice::LoadExtensions() { | |||
| 534 | false); | 546 | false); |
| 535 | Test(extension, has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, | 547 | Test(extension, has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, |
| 536 | false); | 548 | false); |
| 549 | Test(extension, has_ext_custom_border_color, VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME, | ||
| 550 | false); | ||
| 537 | if (Settings::values.renderer_debug) { | 551 | if (Settings::values.renderer_debug) { |
| 538 | Test(extension, nv_device_diagnostics_config, | 552 | Test(extension, nv_device_diagnostics_config, |
| 539 | VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME, true); | 553 | VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME, true); |
| @@ -606,6 +620,19 @@ std::vector<const char*> VKDevice::LoadExtensions() { | |||
| 606 | } | 620 | } |
| 607 | } | 621 | } |
| 608 | 622 | ||
| 623 | if (has_ext_custom_border_color) { | ||
| 624 | VkPhysicalDeviceCustomBorderColorFeaturesEXT border_features; | ||
| 625 | border_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT; | ||
| 626 | border_features.pNext = nullptr; | ||
| 627 | features.pNext = &border_features; | ||
| 628 | physical.GetFeatures2KHR(features); | ||
| 629 | |||
| 630 | if (border_features.customBorderColors && border_features.customBorderColorWithoutFormat) { | ||
| 631 | extensions.push_back(VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); | ||
| 632 | ext_custom_border_color = true; | ||
| 633 | } | ||
| 634 | } | ||
| 635 | |||
| 609 | return extensions; | 636 | return extensions; |
| 610 | } | 637 | } |
| 611 | 638 | ||
diff --git a/src/video_core/renderer_vulkan/vk_device.h b/src/video_core/renderer_vulkan/vk_device.h index c8640762d..ccdf82754 100644 --- a/src/video_core/renderer_vulkan/vk_device.h +++ b/src/video_core/renderer_vulkan/vk_device.h | |||
| @@ -172,6 +172,11 @@ public: | |||
| 172 | return ext_transform_feedback; | 172 | return ext_transform_feedback; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | /// Returns true if the device supports VK_EXT_custom_border_color. | ||
| 176 | bool IsExtCustomBorderColorSupported() const { | ||
| 177 | return ext_custom_border_color; | ||
| 178 | } | ||
| 179 | |||
| 175 | /// Returns the vendor name reported from Vulkan. | 180 | /// Returns the vendor name reported from Vulkan. |
| 176 | std::string_view GetVendorName() const { | 181 | std::string_view GetVendorName() const { |
| 177 | return vendor_name; | 182 | return vendor_name; |
| @@ -227,6 +232,7 @@ private: | |||
| 227 | bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted. | 232 | bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted. |
| 228 | bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer. | 233 | bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer. |
| 229 | bool ext_transform_feedback{}; ///< Support for VK_EXT_transform_feedback. | 234 | bool ext_transform_feedback{}; ///< Support for VK_EXT_transform_feedback. |
| 235 | bool ext_custom_border_color{}; ///< Support for VK_EXT_custom_border_color. | ||
| 230 | bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config. | 236 | bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config. |
| 231 | 237 | ||
| 232 | // Telemetry parameters | 238 | // Telemetry parameters |
diff --git a/src/video_core/renderer_vulkan/vk_sampler_cache.cpp b/src/video_core/renderer_vulkan/vk_sampler_cache.cpp index 2687d8d95..e6f2fa553 100644 --- a/src/video_core/renderer_vulkan/vk_sampler_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_sampler_cache.cpp | |||
| @@ -39,9 +39,18 @@ VKSamplerCache::VKSamplerCache(const VKDevice& device) : device{device} {} | |||
| 39 | VKSamplerCache::~VKSamplerCache() = default; | 39 | VKSamplerCache::~VKSamplerCache() = default; |
| 40 | 40 | ||
| 41 | vk::Sampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc) const { | 41 | vk::Sampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc) const { |
| 42 | const bool arbitrary_borders = device.IsExtCustomBorderColorSupported(); | ||
| 43 | const std::array color = tsc.GetBorderColor(); | ||
| 44 | |||
| 45 | VkSamplerCustomBorderColorCreateInfoEXT border; | ||
| 46 | border.sType = VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT; | ||
| 47 | border.pNext = nullptr; | ||
| 48 | border.format = VK_FORMAT_UNDEFINED; | ||
| 49 | std::memcpy(&border.customBorderColor, color.data(), sizeof(color)); | ||
| 50 | |||
| 42 | VkSamplerCreateInfo ci; | 51 | VkSamplerCreateInfo ci; |
| 43 | ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | 52 | ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 44 | ci.pNext = nullptr; | 53 | ci.pNext = arbitrary_borders ? &border : nullptr; |
| 45 | ci.flags = 0; | 54 | ci.flags = 0; |
| 46 | ci.magFilter = MaxwellToVK::Sampler::Filter(tsc.mag_filter); | 55 | ci.magFilter = MaxwellToVK::Sampler::Filter(tsc.mag_filter); |
| 47 | ci.minFilter = MaxwellToVK::Sampler::Filter(tsc.min_filter); | 56 | ci.minFilter = MaxwellToVK::Sampler::Filter(tsc.min_filter); |
| @@ -56,7 +65,7 @@ vk::Sampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc) c | |||
| 56 | ci.compareOp = MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func); | 65 | ci.compareOp = MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func); |
| 57 | ci.minLod = tsc.GetMinLod(); | 66 | ci.minLod = tsc.GetMinLod(); |
| 58 | ci.maxLod = tsc.GetMaxLod(); | 67 | ci.maxLod = tsc.GetMaxLod(); |
| 59 | ci.borderColor = ConvertBorderColor(tsc.GetBorderColor()); | 68 | ci.borderColor = arbitrary_borders ? VK_BORDER_COLOR_INT_CUSTOM_EXT : ConvertBorderColor(color); |
| 60 | ci.unnormalizedCoordinates = VK_FALSE; | 69 | ci.unnormalizedCoordinates = VK_FALSE; |
| 61 | return device.GetLogical().CreateSampler(ci); | 70 | return device.GetLogical().CreateSampler(ci); |
| 62 | } | 71 | } |
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index fae8638ec..548e4c3fe 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -382,4 +382,18 @@ std::size_t CalculateSize(bool tiled, u32 bytes_per_pixel, u32 width, u32 height | |||
| 382 | } | 382 | } |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | u64 GetGOBOffset(u32 width, u32 height, u32 dst_x, u32 dst_y, u32 block_height, | ||
| 386 | u32 bytes_per_pixel) { | ||
| 387 | auto div_ceil = [](const u32 x, const u32 y) { return ((x + y - 1) / y); }; | ||
| 388 | const u32 gobs_in_block = 1 << block_height; | ||
| 389 | const u32 y_blocks = gob_size_y << block_height; | ||
| 390 | const u32 x_per_gob = gob_size_x / bytes_per_pixel; | ||
| 391 | const u32 x_blocks = div_ceil(width, x_per_gob); | ||
| 392 | const u32 block_size = gob_size * gobs_in_block; | ||
| 393 | const u32 stride = block_size * x_blocks; | ||
| 394 | const u32 base = (dst_y / y_blocks) * stride + (dst_x / x_per_gob) * block_size; | ||
| 395 | const u32 relative_y = dst_y % y_blocks; | ||
| 396 | return base + (relative_y / gob_size_y) * gob_size; | ||
| 397 | } | ||
| 398 | |||
| 385 | } // namespace Tegra::Texture | 399 | } // namespace Tegra::Texture |
diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h index 9f2d6d308..06f3ebf87 100644 --- a/src/video_core/textures/decoders.h +++ b/src/video_core/textures/decoders.h | |||
| @@ -59,4 +59,8 @@ void UnswizzleSubrect(u32 subrect_width, u32 subrect_height, u32 dest_pitch, u32 | |||
| 59 | void SwizzleKepler(u32 width, u32 height, u32 dst_x, u32 dst_y, u32 block_height, | 59 | void SwizzleKepler(u32 width, u32 height, u32 dst_x, u32 dst_y, u32 block_height, |
| 60 | std::size_t copy_size, const u8* source_data, u8* swizzle_data); | 60 | std::size_t copy_size, const u8* source_data, u8* swizzle_data); |
| 61 | 61 | ||
| 62 | /// Obtains the offset of the gob for positions 'dst_x' & 'dst_y' | ||
| 63 | u64 GetGOBOffset(u32 width, u32 height, u32 dst_x, u32 dst_y, u32 block_height, | ||
| 64 | u32 bytes_per_pixel); | ||
| 65 | |||
| 62 | } // namespace Tegra::Texture | 66 | } // namespace Tegra::Texture |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 1cac2f942..3d759f77b 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -292,6 +292,8 @@ GRenderWindow::GRenderWindow(GMainWindow* parent_, EmuThread* emu_thread_) | |||
| 292 | setLayout(layout); | 292 | setLayout(layout); |
| 293 | InputCommon::Init(); | 293 | InputCommon::Init(); |
| 294 | 294 | ||
| 295 | this->setMouseTracking(true); | ||
| 296 | |||
| 295 | connect(this, &GRenderWindow::FirstFrameDisplayed, parent_, &GMainWindow::OnLoadComplete); | 297 | connect(this, &GRenderWindow::FirstFrameDisplayed, parent_, &GMainWindow::OnLoadComplete); |
| 296 | } | 298 | } |
| 297 | 299 | ||
| @@ -385,6 +387,7 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { | |||
| 385 | } else if (event->button() == Qt::RightButton) { | 387 | } else if (event->button() == Qt::RightButton) { |
| 386 | InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y()); | 388 | InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y()); |
| 387 | } | 389 | } |
| 390 | QWidget::mousePressEvent(event); | ||
| 388 | } | 391 | } |
| 389 | 392 | ||
| 390 | void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { | 393 | void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { |
| @@ -397,6 +400,7 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { | |||
| 397 | const auto [x, y] = ScaleTouch(pos); | 400 | const auto [x, y] = ScaleTouch(pos); |
| 398 | this->TouchMoved(x, y); | 401 | this->TouchMoved(x, y); |
| 399 | InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y()); | 402 | InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y()); |
| 403 | QWidget::mouseMoveEvent(event); | ||
| 400 | } | 404 | } |
| 401 | 405 | ||
| 402 | void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { | 406 | void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index a44eed047..75c6cf20b 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -743,6 +743,8 @@ void Config::ReadUIValues() { | |||
| 743 | UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt(); | 743 | UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt(); |
| 744 | UISettings::values.pause_when_in_background = | 744 | UISettings::values.pause_when_in_background = |
| 745 | ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool(); | 745 | ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool(); |
| 746 | UISettings::values.hide_mouse = | ||
| 747 | ReadSetting(QStringLiteral("hideInactiveMouse"), false).toBool(); | ||
| 746 | 748 | ||
| 747 | ApplyDefaultProfileIfInputInvalid(); | 749 | ApplyDefaultProfileIfInputInvalid(); |
| 748 | 750 | ||
| @@ -1169,6 +1171,7 @@ void Config::SaveUIValues() { | |||
| 1169 | WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0); | 1171 | WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0); |
| 1170 | WriteSetting(QStringLiteral("pauseWhenInBackground"), | 1172 | WriteSetting(QStringLiteral("pauseWhenInBackground"), |
| 1171 | UISettings::values.pause_when_in_background, false); | 1173 | UISettings::values.pause_when_in_background, false); |
| 1174 | WriteSetting(QStringLiteral("hideInactiveMouse"), UISettings::values.hide_mouse, false); | ||
| 1172 | 1175 | ||
| 1173 | qt_config->endGroup(); | 1176 | qt_config->endGroup(); |
| 1174 | } | 1177 | } |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 5ef927114..cb95423e0 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -26,6 +26,7 @@ void ConfigureGeneral::SetConfiguration() { | |||
| 26 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); | 26 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); |
| 27 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); | 27 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); |
| 28 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background); | 28 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background); |
| 29 | ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse); | ||
| 29 | 30 | ||
| 30 | ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); | 31 | ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); |
| 31 | ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); | 32 | ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); |
| @@ -36,6 +37,7 @@ void ConfigureGeneral::ApplyConfiguration() { | |||
| 36 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); | 37 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); |
| 37 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); | 38 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); |
| 38 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); | 39 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); |
| 40 | UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); | ||
| 39 | 41 | ||
| 40 | Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); | 42 | Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); |
| 41 | Settings::values.frame_limit = ui->frame_limit->value(); | 43 | Settings::values.frame_limit = ui->frame_limit->value(); |
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index 857119bb3..fc3b7e65a 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui | |||
| @@ -72,6 +72,13 @@ | |||
| 72 | </property> | 72 | </property> |
| 73 | </widget> | 73 | </widget> |
| 74 | </item> | 74 | </item> |
| 75 | <item> | ||
| 76 | <widget class="QCheckBox" name="toggle_hide_mouse"> | ||
| 77 | <property name="text"> | ||
| 78 | <string>Hide mouse on inactivity</string> | ||
| 79 | </property> | ||
| 80 | </widget> | ||
| 81 | </item> | ||
| 75 | </layout> | 82 | </layout> |
| 76 | </item> | 83 | </item> |
| 77 | </layout> | 84 | </layout> |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index b44b4276c..86e8a1d49 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -135,6 +135,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; | |||
| 135 | } | 135 | } |
| 136 | #endif | 136 | #endif |
| 137 | 137 | ||
| 138 | constexpr int default_mouse_timeout = 2500; | ||
| 139 | |||
| 138 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; | 140 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; |
| 139 | 141 | ||
| 140 | /** | 142 | /** |
| @@ -236,6 +238,14 @@ GMainWindow::GMainWindow() | |||
| 236 | // Show one-time "callout" messages to the user | 238 | // Show one-time "callout" messages to the user |
| 237 | ShowTelemetryCallout(); | 239 | ShowTelemetryCallout(); |
| 238 | 240 | ||
| 241 | // make sure menubar has the arrow cursor instead of inheriting from this | ||
| 242 | ui.menubar->setCursor(QCursor()); | ||
| 243 | statusBar()->setCursor(QCursor()); | ||
| 244 | |||
| 245 | mouse_hide_timer.setInterval(default_mouse_timeout); | ||
| 246 | connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); | ||
| 247 | connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); | ||
| 248 | |||
| 239 | QStringList args = QApplication::arguments(); | 249 | QStringList args = QApplication::arguments(); |
| 240 | if (args.length() >= 2) { | 250 | if (args.length() >= 2) { |
| 241 | BootGame(args[1]); | 251 | BootGame(args[1]); |
| @@ -1012,6 +1022,12 @@ void GMainWindow::BootGame(const QString& filename) { | |||
| 1012 | async_status_button->setDisabled(true); | 1022 | async_status_button->setDisabled(true); |
| 1013 | renderer_status_button->setDisabled(true); | 1023 | renderer_status_button->setDisabled(true); |
| 1014 | 1024 | ||
| 1025 | if (UISettings::values.hide_mouse) { | ||
| 1026 | mouse_hide_timer.start(); | ||
| 1027 | setMouseTracking(true); | ||
| 1028 | ui.centralwidget->setMouseTracking(true); | ||
| 1029 | } | ||
| 1030 | |||
| 1015 | const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); | 1031 | const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); |
| 1016 | 1032 | ||
| 1017 | std::string title_name; | 1033 | std::string title_name; |
| @@ -1080,6 +1096,9 @@ void GMainWindow::ShutdownGame() { | |||
| 1080 | game_list->show(); | 1096 | game_list->show(); |
| 1081 | game_list->setFilterFocus(); | 1097 | game_list->setFilterFocus(); |
| 1082 | 1098 | ||
| 1099 | setMouseTracking(false); | ||
| 1100 | ui.centralwidget->setMouseTracking(false); | ||
| 1101 | |||
| 1083 | UpdateWindowTitle(); | 1102 | UpdateWindowTitle(); |
| 1084 | 1103 | ||
| 1085 | // Disable status bar updates | 1104 | // Disable status bar updates |
| @@ -1837,6 +1856,15 @@ void GMainWindow::OnConfigure() { | |||
| 1837 | 1856 | ||
| 1838 | config->Save(); | 1857 | config->Save(); |
| 1839 | 1858 | ||
| 1859 | if (UISettings::values.hide_mouse && emulation_running) { | ||
| 1860 | setMouseTracking(true); | ||
| 1861 | ui.centralwidget->setMouseTracking(true); | ||
| 1862 | mouse_hide_timer.start(); | ||
| 1863 | } else { | ||
| 1864 | setMouseTracking(false); | ||
| 1865 | ui.centralwidget->setMouseTracking(false); | ||
| 1866 | } | ||
| 1867 | |||
| 1840 | dock_status_button->setChecked(Settings::values.use_docked_mode); | 1868 | dock_status_button->setChecked(Settings::values.use_docked_mode); |
| 1841 | async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); | 1869 | async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); |
| 1842 | #ifdef HAS_VULKAN | 1870 | #ifdef HAS_VULKAN |
| @@ -1970,6 +1998,30 @@ void GMainWindow::UpdateStatusBar() { | |||
| 1970 | emu_frametime_label->setVisible(true); | 1998 | emu_frametime_label->setVisible(true); |
| 1971 | } | 1999 | } |
| 1972 | 2000 | ||
| 2001 | void GMainWindow::HideMouseCursor() { | ||
| 2002 | if (emu_thread == nullptr || UISettings::values.hide_mouse == false) { | ||
| 2003 | mouse_hide_timer.stop(); | ||
| 2004 | ShowMouseCursor(); | ||
| 2005 | return; | ||
| 2006 | } | ||
| 2007 | setCursor(QCursor(Qt::BlankCursor)); | ||
| 2008 | } | ||
| 2009 | |||
| 2010 | void GMainWindow::ShowMouseCursor() { | ||
| 2011 | unsetCursor(); | ||
| 2012 | if (emu_thread != nullptr && UISettings::values.hide_mouse) { | ||
| 2013 | mouse_hide_timer.start(); | ||
| 2014 | } | ||
| 2015 | } | ||
| 2016 | |||
| 2017 | void GMainWindow::mouseMoveEvent(QMouseEvent* event) { | ||
| 2018 | ShowMouseCursor(); | ||
| 2019 | } | ||
| 2020 | |||
| 2021 | void GMainWindow::mousePressEvent(QMouseEvent* event) { | ||
| 2022 | ShowMouseCursor(); | ||
| 2023 | } | ||
| 2024 | |||
| 1973 | void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { | 2025 | void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { |
| 1974 | QMessageBox::StandardButton answer; | 2026 | QMessageBox::StandardButton answer; |
| 1975 | QString status_message; | 2027 | QString status_message; |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 0b750689d..60b17c54a 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -216,6 +216,8 @@ private: | |||
| 216 | std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); | 216 | std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); |
| 217 | void UpdateWindowTitle(const QString& title_name = {}); | 217 | void UpdateWindowTitle(const QString& title_name = {}); |
| 218 | void UpdateStatusBar(); | 218 | void UpdateStatusBar(); |
| 219 | void HideMouseCursor(); | ||
| 220 | void ShowMouseCursor(); | ||
| 219 | 221 | ||
| 220 | Ui::MainWindow ui; | 222 | Ui::MainWindow ui; |
| 221 | 223 | ||
| @@ -244,6 +246,7 @@ private: | |||
| 244 | QString game_path; | 246 | QString game_path; |
| 245 | 247 | ||
| 246 | bool auto_paused = false; | 248 | bool auto_paused = false; |
| 249 | QTimer mouse_hide_timer; | ||
| 247 | 250 | ||
| 248 | // FS | 251 | // FS |
| 249 | std::shared_ptr<FileSys::VfsFilesystem> vfs; | 252 | std::shared_ptr<FileSys::VfsFilesystem> vfs; |
| @@ -265,4 +268,6 @@ protected: | |||
| 265 | void dropEvent(QDropEvent* event) override; | 268 | void dropEvent(QDropEvent* event) override; |
| 266 | void dragEnterEvent(QDragEnterEvent* event) override; | 269 | void dragEnterEvent(QDragEnterEvent* event) override; |
| 267 | void dragMoveEvent(QDragMoveEvent* event) override; | 270 | void dragMoveEvent(QDragMoveEvent* event) override; |
| 271 | void mouseMoveEvent(QMouseEvent* event) override; | ||
| 272 | void mousePressEvent(QMouseEvent* event) override; | ||
| 268 | }; | 273 | }; |
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index a675ecf4d..830932d45 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -59,6 +59,7 @@ struct Values { | |||
| 59 | bool confirm_before_closing; | 59 | bool confirm_before_closing; |
| 60 | bool first_start; | 60 | bool first_start; |
| 61 | bool pause_when_in_background; | 61 | bool pause_when_in_background; |
| 62 | bool hide_mouse; | ||
| 62 | 63 | ||
| 63 | bool select_user_on_boot; | 64 | bool select_user_on_boot; |
| 64 | 65 | ||