diff options
36 files changed, 358 insertions, 355 deletions
diff --git a/externals/FidelityFX-FSR/ffx-fsr/ffx_fsr1.h b/externals/FidelityFX-FSR/ffx-fsr/ffx_fsr1.h index 15ecfde5c..4e0b3d548 100644 --- a/externals/FidelityFX-FSR/ffx-fsr/ffx_fsr1.h +++ b/externals/FidelityFX-FSR/ffx-fsr/ffx_fsr1.h | |||
| @@ -747,12 +747,12 @@ AF1 sharpness){ | |||
| 747 | // Immediate constants for peak range. | 747 | // Immediate constants for peak range. |
| 748 | AF2 peakC=AF2(1.0,-1.0*4.0); | 748 | AF2 peakC=AF2(1.0,-1.0*4.0); |
| 749 | // Limiters, these need to be high precision RCPs. | 749 | // Limiters, these need to be high precision RCPs. |
| 750 | AF1 hitMinR=mn4R*ARcpF1(AF1_(4.0)*mx4R); | 750 | AF1 hitMinR=min(mn4R,eR)*ARcpF1(AF1_(4.0)*mx4R); |
| 751 | AF1 hitMinG=mn4G*ARcpF1(AF1_(4.0)*mx4G); | 751 | AF1 hitMinG=min(mn4G,eG)*ARcpF1(AF1_(4.0)*mx4G); |
| 752 | AF1 hitMinB=mn4B*ARcpF1(AF1_(4.0)*mx4B); | 752 | AF1 hitMinB=min(mn4B,eB)*ARcpF1(AF1_(4.0)*mx4B); |
| 753 | AF1 hitMaxR=(peakC.x-mx4R)*ARcpF1(AF1_(4.0)*mn4R+peakC.y); | 753 | AF1 hitMaxR=(peakC.x-max(mx4R,eR))*ARcpF1(AF1_(4.0)*mn4R+peakC.y); |
| 754 | AF1 hitMaxG=(peakC.x-mx4G)*ARcpF1(AF1_(4.0)*mn4G+peakC.y); | 754 | AF1 hitMaxG=(peakC.x-max(mx4G,eG))*ARcpF1(AF1_(4.0)*mn4G+peakC.y); |
| 755 | AF1 hitMaxB=(peakC.x-mx4B)*ARcpF1(AF1_(4.0)*mn4B+peakC.y); | 755 | AF1 hitMaxB=(peakC.x-max(mx4B,eB))*ARcpF1(AF1_(4.0)*mn4B+peakC.y); |
| 756 | AF1 lobeR=max(-hitMinR,hitMaxR); | 756 | AF1 lobeR=max(-hitMinR,hitMaxR); |
| 757 | AF1 lobeG=max(-hitMinG,hitMaxG); | 757 | AF1 lobeG=max(-hitMinG,hitMaxG); |
| 758 | AF1 lobeB=max(-hitMinB,hitMaxB); | 758 | AF1 lobeB=max(-hitMinB,hitMaxB); |
| @@ -845,12 +845,12 @@ AF1 sharpness){ | |||
| 845 | // Immediate constants for peak range. | 845 | // Immediate constants for peak range. |
| 846 | AH2 peakC=AH2(1.0,-1.0*4.0); | 846 | AH2 peakC=AH2(1.0,-1.0*4.0); |
| 847 | // Limiters, these need to be high precision RCPs. | 847 | // Limiters, these need to be high precision RCPs. |
| 848 | AH1 hitMinR=mn4R*ARcpH1(AH1_(4.0)*mx4R); | 848 | AH1 hitMinR=min(mn4R,eR)*ARcpH1(AH1_(4.0)*mx4R); |
| 849 | AH1 hitMinG=mn4G*ARcpH1(AH1_(4.0)*mx4G); | 849 | AH1 hitMinG=min(mn4G,eG)*ARcpH1(AH1_(4.0)*mx4G); |
| 850 | AH1 hitMinB=mn4B*ARcpH1(AH1_(4.0)*mx4B); | 850 | AH1 hitMinB=min(mn4B,eB)*ARcpH1(AH1_(4.0)*mx4B); |
| 851 | AH1 hitMaxR=(peakC.x-mx4R)*ARcpH1(AH1_(4.0)*mn4R+peakC.y); | 851 | AH1 hitMaxR=(peakC.x-max(mx4R,eR))*ARcpH1(AH1_(4.0)*mn4R+peakC.y); |
| 852 | AH1 hitMaxG=(peakC.x-mx4G)*ARcpH1(AH1_(4.0)*mn4G+peakC.y); | 852 | AH1 hitMaxG=(peakC.x-max(mx4G,eG))*ARcpH1(AH1_(4.0)*mn4G+peakC.y); |
| 853 | AH1 hitMaxB=(peakC.x-mx4B)*ARcpH1(AH1_(4.0)*mn4B+peakC.y); | 853 | AH1 hitMaxB=(peakC.x-max(mx4B,eB))*ARcpH1(AH1_(4.0)*mn4B+peakC.y); |
| 854 | AH1 lobeR=max(-hitMinR,hitMaxR); | 854 | AH1 lobeR=max(-hitMinR,hitMaxR); |
| 855 | AH1 lobeG=max(-hitMinG,hitMaxG); | 855 | AH1 lobeG=max(-hitMinG,hitMaxG); |
| 856 | AH1 lobeB=max(-hitMinB,hitMaxB); | 856 | AH1 lobeB=max(-hitMinB,hitMaxB); |
| @@ -963,12 +963,12 @@ AF1 sharpness){ | |||
| 963 | // Immediate constants for peak range. | 963 | // Immediate constants for peak range. |
| 964 | AH2 peakC=AH2(1.0,-1.0*4.0); | 964 | AH2 peakC=AH2(1.0,-1.0*4.0); |
| 965 | // Limiters, these need to be high precision RCPs. | 965 | // Limiters, these need to be high precision RCPs. |
| 966 | AH2 hitMinR=mn4R*ARcpH2(AH2_(4.0)*mx4R); | 966 | AH2 hitMinR=min(mn4R,eR)*ARcpH2(AH2_(4.0)*mx4R); |
| 967 | AH2 hitMinG=mn4G*ARcpH2(AH2_(4.0)*mx4G); | 967 | AH2 hitMinG=min(mn4G,eG)*ARcpH2(AH2_(4.0)*mx4G); |
| 968 | AH2 hitMinB=mn4B*ARcpH2(AH2_(4.0)*mx4B); | 968 | AH2 hitMinB=min(mn4B,eB)*ARcpH2(AH2_(4.0)*mx4B); |
| 969 | AH2 hitMaxR=(peakC.x-mx4R)*ARcpH2(AH2_(4.0)*mn4R+peakC.y); | 969 | AH2 hitMaxR=(peakC.x-max(mx4R,eR))*ARcpH2(AH2_(4.0)*mn4R+peakC.y); |
| 970 | AH2 hitMaxG=(peakC.x-mx4G)*ARcpH2(AH2_(4.0)*mn4G+peakC.y); | 970 | AH2 hitMaxG=(peakC.x-max(mx4G,eG))*ARcpH2(AH2_(4.0)*mn4G+peakC.y); |
| 971 | AH2 hitMaxB=(peakC.x-mx4B)*ARcpH2(AH2_(4.0)*mn4B+peakC.y); | 971 | AH2 hitMaxB=(peakC.x-max(mx4B,eB))*ARcpH2(AH2_(4.0)*mn4B+peakC.y); |
| 972 | AH2 lobeR=max(-hitMinR,hitMaxR); | 972 | AH2 lobeR=max(-hitMinR,hitMaxR); |
| 973 | AH2 lobeG=max(-hitMinG,hitMaxG); | 973 | AH2 lobeG=max(-hitMinG,hitMaxG); |
| 974 | AH2 lobeB=max(-hitMinB,hitMaxB); | 974 | AH2 lobeB=max(-hitMinB,hitMaxB); |
diff --git a/externals/ffmpeg/CMakeLists.txt b/externals/ffmpeg/CMakeLists.txt index c57b54f77..be8325b47 100644 --- a/externals/ffmpeg/CMakeLists.txt +++ b/externals/ffmpeg/CMakeLists.txt | |||
| @@ -95,7 +95,8 @@ if (NOT WIN32) | |||
| 95 | # ffnvenc could load CUDA libraries at the runtime using dlopen/dlsym or LoadLibrary/GetProcAddress | 95 | # ffnvenc could load CUDA libraries at the runtime using dlopen/dlsym or LoadLibrary/GetProcAddress |
| 96 | # here we handle the hard-linking senario where CUDA is linked during compilation | 96 | # here we handle the hard-linking senario where CUDA is linked during compilation |
| 97 | if (CUDA_FOUND) | 97 | if (CUDA_FOUND) |
| 98 | list(APPEND FFmpeg_HWACCEL_FLAGS --extra-cflags=-I${CUDA_INCLUDE_DIRS}) | 98 | # This line causes build error if CUDA_INCLUDE_DIRS is anything but a single non-empty value |
| 99 | #list(APPEND FFmpeg_HWACCEL_FLAGS --extra-cflags=-I${CUDA_INCLUDE_DIRS}) | ||
| 99 | list(APPEND FFmpeg_HWACCEL_LIBRARIES ${CUDA_LIBRARIES}) | 100 | list(APPEND FFmpeg_HWACCEL_LIBRARIES ${CUDA_LIBRARIES}) |
| 100 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS}) | 101 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS}) |
| 101 | list(APPEND FFmpeg_HWACCEL_LDFLAGS ${CUDA_LDFLAGS}) | 102 | list(APPEND FFmpeg_HWACCEL_LDFLAGS ${CUDA_LDFLAGS}) |
| @@ -119,6 +120,8 @@ if (NOT WIN32) | |||
| 119 | 120 | ||
| 120 | # `configure` parameters builds only exactly what yuzu needs from FFmpeg | 121 | # `configure` parameters builds only exactly what yuzu needs from FFmpeg |
| 121 | # `--disable-vdpau` is needed to avoid linking issues | 122 | # `--disable-vdpau` is needed to avoid linking issues |
| 123 | set(FFmpeg_CC ${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER}) | ||
| 124 | set(FFmpeg_CXX ${CMAKE_CXX_COMPILER_LAUNCHER} ${CMAKE_CXX_COMPILER}) | ||
| 122 | add_custom_command( | 125 | add_custom_command( |
| 123 | OUTPUT | 126 | OUTPUT |
| 124 | ${FFmpeg_MAKEFILE} | 127 | ${FFmpeg_MAKEFILE} |
| @@ -137,12 +140,14 @@ if (NOT WIN32) | |||
| 137 | --enable-decoder=h264 | 140 | --enable-decoder=h264 |
| 138 | --enable-decoder=vp8 | 141 | --enable-decoder=vp8 |
| 139 | --enable-decoder=vp9 | 142 | --enable-decoder=vp9 |
| 140 | --cc="${CMAKE_C_COMPILER}" | 143 | --cc="${FFmpeg_CC}" |
| 141 | --cxx="${CMAKE_CXX_COMPILER}" | 144 | --cxx="${FFmpeg_CXX}" |
| 142 | ${FFmpeg_HWACCEL_FLAGS} | 145 | ${FFmpeg_HWACCEL_FLAGS} |
| 143 | WORKING_DIRECTORY | 146 | WORKING_DIRECTORY |
| 144 | ${FFmpeg_BUILD_DIR} | 147 | ${FFmpeg_BUILD_DIR} |
| 145 | ) | 148 | ) |
| 149 | unset(FFmpeg_CC) | ||
| 150 | unset(FFmpeg_CXX) | ||
| 146 | unset(FFmpeg_HWACCEL_FLAGS) | 151 | unset(FFmpeg_HWACCEL_FLAGS) |
| 147 | 152 | ||
| 148 | # Workaround for Ubuntu 18.04's older version of make not being able to call make as a child | 153 | # Workaround for Ubuntu 18.04's older version of make not being able to call make as a child |
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index 5a30f55a7..0abc989b2 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp | |||
| @@ -79,8 +79,8 @@ static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) { | |||
| 79 | return; | 79 | return; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | // Implementation of a volume slider with a dynamic range of 60 dB | 82 | // Perceived volume is not the same as the volume level |
| 83 | const float volume_scale_factor = volume == 0 ? 0 : std::exp(6.90775f * volume) * 0.001f; | 83 | const float volume_scale_factor = (0.85f * ((volume * volume) - volume)) + volume; |
| 84 | for (auto& sample : samples) { | 84 | for (auto& sample : samples) { |
| 85 | sample = static_cast<s16>(sample * volume_scale_factor); | 85 | sample = static_cast<s16>(sample * volume_scale_factor); |
| 86 | } | 86 | } |
diff --git a/src/common/settings.h b/src/common/settings.h index d01c0448c..9bee6e10f 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -554,6 +554,7 @@ struct Values { | |||
| 554 | Setting<bool> use_docked_mode{true, "use_docked_mode"}; | 554 | Setting<bool> use_docked_mode{true, "use_docked_mode"}; |
| 555 | 555 | ||
| 556 | BasicSetting<bool> enable_raw_input{false, "enable_raw_input"}; | 556 | BasicSetting<bool> enable_raw_input{false, "enable_raw_input"}; |
| 557 | BasicSetting<bool> controller_navigation{true, "controller_navigation"}; | ||
| 557 | 558 | ||
| 558 | Setting<bool> vibration_enabled{true, "vibration_enabled"}; | 559 | Setting<bool> vibration_enabled{true, "vibration_enabled"}; |
| 559 | Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"}; | 560 | Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"}; |
diff --git a/src/core/hle/kernel/k_affinity_mask.h b/src/core/hle/kernel/k_affinity_mask.h index b906895fc..cf704ce87 100644 --- a/src/core/hle/kernel/k_affinity_mask.h +++ b/src/core/hle/kernel/k_affinity_mask.h | |||
| @@ -31,8 +31,6 @@ public: | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | constexpr void SetAffinity(s32 core, bool set) { | 33 | constexpr void SetAffinity(s32 core, bool set) { |
| 34 | ASSERT(0 <= core && core < static_cast<s32>(Core::Hardware::NUM_CPU_CORES)); | ||
| 35 | |||
| 36 | if (set) { | 34 | if (set) { |
| 37 | this->mask |= GetCoreBit(core); | 35 | this->mask |= GetCoreBit(core); |
| 38 | } else { | 36 | } else { |
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 265ac6fa1..85c506979 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp | |||
| @@ -146,6 +146,13 @@ ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::st | |||
| 146 | // Open a reference to the resource limit. | 146 | // Open a reference to the resource limit. |
| 147 | process->resource_limit->Open(); | 147 | process->resource_limit->Open(); |
| 148 | 148 | ||
| 149 | // Clear remaining fields. | ||
| 150 | process->num_running_threads = 0; | ||
| 151 | process->is_signaled = false; | ||
| 152 | process->exception_thread = nullptr; | ||
| 153 | process->is_suspended = false; | ||
| 154 | process->schedule_count = 0; | ||
| 155 | |||
| 149 | return ResultSuccess; | 156 | return ResultSuccess; |
| 150 | } | 157 | } |
| 151 | 158 | ||
| @@ -157,20 +164,17 @@ KResourceLimit* KProcess::GetResourceLimit() const { | |||
| 157 | return resource_limit; | 164 | return resource_limit; |
| 158 | } | 165 | } |
| 159 | 166 | ||
| 160 | void KProcess::IncrementThreadCount() { | 167 | void KProcess::IncrementRunningThreadCount() { |
| 161 | ASSERT(num_threads >= 0); | 168 | ASSERT(num_running_threads.load() >= 0); |
| 162 | num_created_threads++; | 169 | ++num_running_threads; |
| 163 | |||
| 164 | if (const auto count = ++num_threads; count > peak_num_threads) { | ||
| 165 | peak_num_threads = count; | ||
| 166 | } | ||
| 167 | } | 170 | } |
| 168 | 171 | ||
| 169 | void KProcess::DecrementThreadCount() { | 172 | void KProcess::DecrementRunningThreadCount() { |
| 170 | ASSERT(num_threads > 0); | 173 | ASSERT(num_running_threads.load() > 0); |
| 171 | 174 | ||
| 172 | if (const auto count = --num_threads; count == 0) { | 175 | if (const auto prev = num_running_threads--; prev == 1) { |
| 173 | LOG_WARNING(Kernel, "Process termination is not fully implemented."); | 176 | // TODO(bunnei): Process termination to be implemented when multiprocess is supported. |
| 177 | UNIMPLEMENTED_MSG("KProcess termination is not implemennted!"); | ||
| 174 | } | 178 | } |
| 175 | } | 179 | } |
| 176 | 180 | ||
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index c2a672021..38b446350 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h | |||
| @@ -235,8 +235,8 @@ public: | |||
| 235 | ++schedule_count; | 235 | ++schedule_count; |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | void IncrementThreadCount(); | 238 | void IncrementRunningThreadCount(); |
| 239 | void DecrementThreadCount(); | 239 | void DecrementRunningThreadCount(); |
| 240 | 240 | ||
| 241 | void SetRunningThread(s32 core, KThread* thread, u64 idle_count) { | 241 | void SetRunningThread(s32 core, KThread* thread, u64 idle_count) { |
| 242 | running_threads[core] = thread; | 242 | running_threads[core] = thread; |
| @@ -473,9 +473,7 @@ private: | |||
| 473 | bool is_suspended{}; | 473 | bool is_suspended{}; |
| 474 | bool is_initialized{}; | 474 | bool is_initialized{}; |
| 475 | 475 | ||
| 476 | std::atomic<s32> num_created_threads{}; | 476 | std::atomic<u16> num_running_threads{}; |
| 477 | std::atomic<u16> num_threads{}; | ||
| 478 | u16 peak_num_threads{}; | ||
| 479 | 477 | ||
| 480 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> running_threads{}; | 478 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> running_threads{}; |
| 481 | std::array<u64, Core::Hardware::NUM_CPU_CORES> running_thread_idle_counts{}; | 479 | std::array<u64, Core::Hardware::NUM_CPU_CORES> running_thread_idle_counts{}; |
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index f42abb8a1..de3ffe0c7 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp | |||
| @@ -215,7 +215,6 @@ ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_s | |||
| 215 | 215 | ||
| 216 | parent = owner; | 216 | parent = owner; |
| 217 | parent->Open(); | 217 | parent->Open(); |
| 218 | parent->IncrementThreadCount(); | ||
| 219 | } | 218 | } |
| 220 | 219 | ||
| 221 | // Initialize thread context. | 220 | // Initialize thread context. |
| @@ -327,11 +326,6 @@ void KThread::Finalize() { | |||
| 327 | } | 326 | } |
| 328 | } | 327 | } |
| 329 | 328 | ||
| 330 | // Decrement the parent process's thread count. | ||
| 331 | if (parent != nullptr) { | ||
| 332 | parent->DecrementThreadCount(); | ||
| 333 | } | ||
| 334 | |||
| 335 | // Perform inherited finalization. | 329 | // Perform inherited finalization. |
| 336 | KSynchronizationObject::Finalize(); | 330 | KSynchronizationObject::Finalize(); |
| 337 | } | 331 | } |
| @@ -1011,7 +1005,7 @@ ResultCode KThread::Run() { | |||
| 1011 | if (IsUserThread() && IsSuspended()) { | 1005 | if (IsUserThread() && IsSuspended()) { |
| 1012 | this->UpdateState(); | 1006 | this->UpdateState(); |
| 1013 | } | 1007 | } |
| 1014 | owner->IncrementThreadCount(); | 1008 | owner->IncrementRunningThreadCount(); |
| 1015 | } | 1009 | } |
| 1016 | 1010 | ||
| 1017 | // Set our state and finish. | 1011 | // Set our state and finish. |
| @@ -1026,10 +1020,11 @@ ResultCode KThread::Run() { | |||
| 1026 | void KThread::Exit() { | 1020 | void KThread::Exit() { |
| 1027 | ASSERT(this == GetCurrentThreadPointer(kernel)); | 1021 | ASSERT(this == GetCurrentThreadPointer(kernel)); |
| 1028 | 1022 | ||
| 1029 | // Release the thread resource hint from parent. | 1023 | // Release the thread resource hint, running thread count from parent. |
| 1030 | if (parent != nullptr) { | 1024 | if (parent != nullptr) { |
| 1031 | parent->GetResourceLimit()->Release(Kernel::LimitableResource::Threads, 0, 1); | 1025 | parent->GetResourceLimit()->Release(Kernel::LimitableResource::Threads, 0, 1); |
| 1032 | resource_limit_release_hint = true; | 1026 | resource_limit_release_hint = true; |
| 1027 | parent->DecrementRunningThreadCount(); | ||
| 1033 | } | 1028 | } |
| 1034 | 1029 | ||
| 1035 | // Perform termination. | 1030 | // Perform termination. |
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index 9aaeb91be..d1cdb1ab2 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp | |||
| @@ -339,7 +339,7 @@ void UDPClient::StartCommunication(std::size_t client, const std::string& host, | |||
| 339 | } | 339 | } |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | const PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const { | 342 | PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const { |
| 343 | const std::size_t client = pad_index / PADS_PER_CLIENT; | 343 | const std::size_t client = pad_index / PADS_PER_CLIENT; |
| 344 | return { | 344 | return { |
| 345 | .guid = clients[client].uuid, | 345 | .guid = clients[client].uuid, |
| @@ -348,9 +348,9 @@ const PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const { | |||
| 348 | }; | 348 | }; |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | const Common::UUID UDPClient::GetHostUUID(const std::string host) const { | 351 | Common::UUID UDPClient::GetHostUUID(const std::string& host) const { |
| 352 | const auto ip = boost::asio::ip::address_v4::from_string(host); | 352 | const auto ip = boost::asio::ip::make_address_v4(host); |
| 353 | const auto hex_host = fmt::format("{:06x}", ip.to_ulong()); | 353 | const auto hex_host = fmt::format("{:06x}", ip.to_uint()); |
| 354 | return Common::UUID{hex_host}; | 354 | return Common::UUID{hex_host}; |
| 355 | } | 355 | } |
| 356 | 356 | ||
diff --git a/src/input_common/drivers/udp_client.h b/src/input_common/drivers/udp_client.h index 61a1fff37..30d7c2682 100644 --- a/src/input_common/drivers/udp_client.h +++ b/src/input_common/drivers/udp_client.h | |||
| @@ -145,8 +145,8 @@ private: | |||
| 145 | void OnPortInfo(Response::PortInfo); | 145 | void OnPortInfo(Response::PortInfo); |
| 146 | void OnPadData(Response::PadData, std::size_t client); | 146 | void OnPadData(Response::PadData, std::size_t client); |
| 147 | void StartCommunication(std::size_t client, const std::string& host, u16 port); | 147 | void StartCommunication(std::size_t client, const std::string& host, u16 port); |
| 148 | const PadIdentifier GetPadIdentifier(std::size_t pad_index) const; | 148 | PadIdentifier GetPadIdentifier(std::size_t pad_index) const; |
| 149 | const Common::UUID GetHostUUID(const std::string host) const; | 149 | Common::UUID GetHostUUID(const std::string& host) const; |
| 150 | 150 | ||
| 151 | Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; | 151 | Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; |
| 152 | 152 | ||
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index 390581c94..fe2faee5a 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | // Pad Identifier of data source | 17 | // Pad Identifier of data source |
| 18 | struct PadIdentifier { | 18 | struct PadIdentifier { |
| 19 | Common::UUID guid{}; | 19 | Common::UUID guid{Common::INVALID_UUID}; |
| 20 | std::size_t port{}; | 20 | std::size_t port{}; |
| 21 | std::size_t pad{}; | 21 | std::size_t pad{}; |
| 22 | 22 | ||
| @@ -89,7 +89,7 @@ struct UpdateCallback { | |||
| 89 | 89 | ||
| 90 | // Triggered if data changed on the controller and the engine is on configuring mode | 90 | // Triggered if data changed on the controller and the engine is on configuring mode |
| 91 | struct MappingCallback { | 91 | struct MappingCallback { |
| 92 | std::function<void(MappingData)> on_data; | 92 | std::function<void(const MappingData&)> on_data; |
| 93 | }; | 93 | }; |
| 94 | 94 | ||
| 95 | // Input Identifier of data source | 95 | // Input Identifier of data source |
diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp index 475257f42..a7a6ad8c2 100644 --- a/src/input_common/input_mapping.cpp +++ b/src/input_common/input_mapping.cpp | |||
| @@ -2,14 +2,13 @@ | |||
| 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 | #include "common/common_types.h" | ||
| 6 | #include "common/settings.h" | 5 | #include "common/settings.h" |
| 7 | #include "input_common/input_engine.h" | 6 | #include "input_common/input_engine.h" |
| 8 | #include "input_common/input_mapping.h" | 7 | #include "input_common/input_mapping.h" |
| 9 | 8 | ||
| 10 | namespace InputCommon { | 9 | namespace InputCommon { |
| 11 | 10 | ||
| 12 | MappingFactory::MappingFactory() {} | 11 | MappingFactory::MappingFactory() = default; |
| 13 | 12 | ||
| 14 | void MappingFactory::BeginMapping(Polling::InputType type) { | 13 | void MappingFactory::BeginMapping(Polling::InputType type) { |
| 15 | is_enabled = true; | 14 | is_enabled = true; |
| @@ -19,7 +18,7 @@ void MappingFactory::BeginMapping(Polling::InputType type) { | |||
| 19 | second_axis = -1; | 18 | second_axis = -1; |
| 20 | } | 19 | } |
| 21 | 20 | ||
| 22 | [[nodiscard]] const Common::ParamPackage MappingFactory::GetNextInput() { | 21 | Common::ParamPackage MappingFactory::GetNextInput() { |
| 23 | Common::ParamPackage input; | 22 | Common::ParamPackage input; |
| 24 | input_queue.Pop(input); | 23 | input_queue.Pop(input); |
| 25 | return input; | 24 | return input; |
| @@ -57,7 +56,7 @@ void MappingFactory::StopMapping() { | |||
| 57 | void MappingFactory::RegisterButton(const MappingData& data) { | 56 | void MappingFactory::RegisterButton(const MappingData& data) { |
| 58 | Common::ParamPackage new_input; | 57 | Common::ParamPackage new_input; |
| 59 | new_input.Set("engine", data.engine); | 58 | new_input.Set("engine", data.engine); |
| 60 | if (data.pad.guid != Common::UUID{}) { | 59 | if (data.pad.guid.IsValid()) { |
| 61 | new_input.Set("guid", data.pad.guid.Format()); | 60 | new_input.Set("guid", data.pad.guid.Format()); |
| 62 | } | 61 | } |
| 63 | new_input.Set("port", static_cast<int>(data.pad.port)); | 62 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| @@ -93,7 +92,7 @@ void MappingFactory::RegisterButton(const MappingData& data) { | |||
| 93 | void MappingFactory::RegisterStick(const MappingData& data) { | 92 | void MappingFactory::RegisterStick(const MappingData& data) { |
| 94 | Common::ParamPackage new_input; | 93 | Common::ParamPackage new_input; |
| 95 | new_input.Set("engine", data.engine); | 94 | new_input.Set("engine", data.engine); |
| 96 | if (data.pad.guid != Common::UUID{}) { | 95 | if (data.pad.guid.IsValid()) { |
| 97 | new_input.Set("guid", data.pad.guid.Format()); | 96 | new_input.Set("guid", data.pad.guid.Format()); |
| 98 | } | 97 | } |
| 99 | new_input.Set("port", static_cast<int>(data.pad.port)); | 98 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| @@ -138,7 +137,7 @@ void MappingFactory::RegisterStick(const MappingData& data) { | |||
| 138 | void MappingFactory::RegisterMotion(const MappingData& data) { | 137 | void MappingFactory::RegisterMotion(const MappingData& data) { |
| 139 | Common::ParamPackage new_input; | 138 | Common::ParamPackage new_input; |
| 140 | new_input.Set("engine", data.engine); | 139 | new_input.Set("engine", data.engine); |
| 141 | if (data.pad.guid != Common::UUID{}) { | 140 | if (data.pad.guid.IsValid()) { |
| 142 | new_input.Set("guid", data.pad.guid.Format()); | 141 | new_input.Set("guid", data.pad.guid.Format()); |
| 143 | } | 142 | } |
| 144 | new_input.Set("port", static_cast<int>(data.pad.port)); | 143 | new_input.Set("port", static_cast<int>(data.pad.port)); |
diff --git a/src/input_common/input_mapping.h b/src/input_common/input_mapping.h index 93564b5f8..e0dfbc7ad 100644 --- a/src/input_common/input_mapping.h +++ b/src/input_common/input_mapping.h | |||
| @@ -3,8 +3,14 @@ | |||
| 3 | // Refer to the license.txt file included | 3 | // Refer to the license.txt file included |
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | |||
| 7 | #include "common/param_package.h" | ||
| 6 | #include "common/threadsafe_queue.h" | 8 | #include "common/threadsafe_queue.h" |
| 7 | 9 | ||
| 10 | namespace InputCommon::Polling { | ||
| 11 | enum class InputType; | ||
| 12 | } | ||
| 13 | |||
| 8 | namespace InputCommon { | 14 | namespace InputCommon { |
| 9 | class InputEngine; | 15 | class InputEngine; |
| 10 | struct MappingData; | 16 | struct MappingData; |
| @@ -20,7 +26,7 @@ public: | |||
| 20 | void BeginMapping(Polling::InputType type); | 26 | void BeginMapping(Polling::InputType type); |
| 21 | 27 | ||
| 22 | /// Returns an input event with mapping information from the input_queue | 28 | /// Returns an input event with mapping information from the input_queue |
| 23 | [[nodiscard]] const Common::ParamPackage GetNextInput(); | 29 | [[nodiscard]] Common::ParamPackage GetNextInput(); |
| 24 | 30 | ||
| 25 | /** | 31 | /** |
| 26 | * Registers mapping input data from the driver | 32 | * Registers mapping input data from the driver |
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 940744c5f..a4d7ed645 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -27,7 +27,7 @@ namespace InputCommon { | |||
| 27 | struct InputSubsystem::Impl { | 27 | struct InputSubsystem::Impl { |
| 28 | void Initialize() { | 28 | void Initialize() { |
| 29 | mapping_factory = std::make_shared<MappingFactory>(); | 29 | mapping_factory = std::make_shared<MappingFactory>(); |
| 30 | MappingCallback mapping_callback{[this](MappingData data) { RegisterInput(data); }}; | 30 | MappingCallback mapping_callback{[this](const MappingData& data) { RegisterInput(data); }}; |
| 31 | 31 | ||
| 32 | keyboard = std::make_shared<Keyboard>("keyboard"); | 32 | keyboard = std::make_shared<Keyboard>("keyboard"); |
| 33 | keyboard->SetMappingCallback(mapping_callback); | 33 | keyboard->SetMappingCallback(mapping_callback); |
| @@ -284,7 +284,7 @@ struct InputSubsystem::Impl { | |||
| 284 | #endif | 284 | #endif |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | void RegisterInput(MappingData data) { | 287 | void RegisterInput(const MappingData& data) { |
| 288 | mapping_factory->RegisterInput(data); | 288 | mapping_factory->RegisterInput(data); |
| 289 | } | 289 | } |
| 290 | 290 | ||
| @@ -394,7 +394,7 @@ void InputSubsystem::BeginMapping(Polling::InputType type) { | |||
| 394 | impl->mapping_factory->BeginMapping(type); | 394 | impl->mapping_factory->BeginMapping(type); |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | const Common::ParamPackage InputSubsystem::GetNextInput() const { | 397 | Common::ParamPackage InputSubsystem::GetNextInput() const { |
| 398 | return impl->mapping_factory->GetNextInput(); | 398 | return impl->mapping_factory->GetNextInput(); |
| 399 | } | 399 | } |
| 400 | 400 | ||
diff --git a/src/input_common/main.h b/src/input_common/main.h index c6f97f691..baf107e0f 100644 --- a/src/input_common/main.h +++ b/src/input_common/main.h | |||
| @@ -126,7 +126,7 @@ public: | |||
| 126 | void BeginMapping(Polling::InputType type); | 126 | void BeginMapping(Polling::InputType type); |
| 127 | 127 | ||
| 128 | /// Returns an input event with mapping information. | 128 | /// Returns an input event with mapping information. |
| 129 | [[nodiscard]] const Common::ParamPackage GetNextInput() const; | 129 | [[nodiscard]] Common::ParamPackage GetNextInput() const; |
| 130 | 130 | ||
| 131 | /// Stop polling from all backends. | 131 | /// Stop polling from all backends. |
| 132 | void StopMapping() const; | 132 | void StopMapping() const; |
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.h b/src/shader_recompiler/frontend/maxwell/translate_program.h index cd535f20d..eac83da9d 100644 --- a/src/shader_recompiler/frontend/maxwell/translate_program.h +++ b/src/shader_recompiler/frontend/maxwell/translate_program.h | |||
| @@ -21,7 +21,6 @@ namespace Shader::Maxwell { | |||
| 21 | [[nodiscard]] IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b, | 21 | [[nodiscard]] IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b, |
| 22 | Environment& env_vertex_b); | 22 | Environment& env_vertex_b); |
| 23 | 23 | ||
| 24 | [[nodiscard]] void ConvertLegacyToGeneric(IR::Program& program, | 24 | void ConvertLegacyToGeneric(IR::Program& program, const RuntimeInfo& runtime_info); |
| 25 | const Shader::RuntimeInfo& runtime_info); | ||
| 26 | 25 | ||
| 27 | } // namespace Shader::Maxwell | 26 | } // namespace Shader::Maxwell |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index b18b8a02a..c38ebd670 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -240,7 +240,7 @@ void Maxwell3D::CallMacroMethod(u32 method, const std::vector<u32>& parameters) | |||
| 240 | ((method - MacroRegistersStart) >> 1) % static_cast<u32>(macro_positions.size()); | 240 | ((method - MacroRegistersStart) >> 1) % static_cast<u32>(macro_positions.size()); |
| 241 | 241 | ||
| 242 | // Execute the current macro. | 242 | // Execute the current macro. |
| 243 | macro_engine->Execute(*this, macro_positions[entry], parameters); | 243 | macro_engine->Execute(macro_positions[entry], parameters); |
| 244 | if (mme_draw.current_mode != MMEDrawMode::Undefined) { | 244 | if (mme_draw.current_mode != MMEDrawMode::Undefined) { |
| 245 | FlushMMEInlineDraw(); | 245 | FlushMMEInlineDraw(); |
| 246 | } | 246 | } |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 3188b83ed..26b8ea233 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -12,9 +12,6 @@ | |||
| 12 | #include "video_core/framebuffer_config.h" | 12 | #include "video_core/framebuffer_config.h" |
| 13 | 13 | ||
| 14 | namespace Core { | 14 | namespace Core { |
| 15 | namespace Frontend { | ||
| 16 | class EmuWindow; | ||
| 17 | } | ||
| 18 | class System; | 15 | class System; |
| 19 | } // namespace Core | 16 | } // namespace Core |
| 20 | 17 | ||
| @@ -25,7 +22,6 @@ class ShaderNotify; | |||
| 25 | 22 | ||
| 26 | namespace Tegra { | 23 | namespace Tegra { |
| 27 | class DmaPusher; | 24 | class DmaPusher; |
| 28 | class CDmaPusher; | ||
| 29 | struct CommandList; | 25 | struct CommandList; |
| 30 | 26 | ||
| 31 | enum class RenderTargetFormat : u32 { | 27 | enum class RenderTargetFormat : u32 { |
| @@ -88,15 +84,9 @@ enum class DepthFormat : u32 { | |||
| 88 | D32_FLOAT_S8X24_UINT = 0x19, | 84 | D32_FLOAT_S8X24_UINT = 0x19, |
| 89 | }; | 85 | }; |
| 90 | 86 | ||
| 91 | struct CommandListHeader; | ||
| 92 | class DebugContext; | ||
| 93 | |||
| 94 | namespace Engines { | 87 | namespace Engines { |
| 95 | class Fermi2D; | ||
| 96 | class Maxwell3D; | 88 | class Maxwell3D; |
| 97 | class MaxwellDMA; | ||
| 98 | class KeplerCompute; | 89 | class KeplerCompute; |
| 99 | class KeplerMemory; | ||
| 100 | } // namespace Engines | 90 | } // namespace Engines |
| 101 | 91 | ||
| 102 | enum class EngineID { | 92 | enum class EngineID { |
| @@ -190,12 +180,6 @@ public: | |||
| 190 | /// Returns a const reference to the GPU DMA pusher. | 180 | /// Returns a const reference to the GPU DMA pusher. |
| 191 | [[nodiscard]] const Tegra::DmaPusher& DmaPusher() const; | 181 | [[nodiscard]] const Tegra::DmaPusher& DmaPusher() const; |
| 192 | 182 | ||
| 193 | /// Returns a reference to the GPU CDMA pusher. | ||
| 194 | [[nodiscard]] Tegra::CDmaPusher& CDmaPusher(); | ||
| 195 | |||
| 196 | /// Returns a const reference to the GPU CDMA pusher. | ||
| 197 | [[nodiscard]] const Tegra::CDmaPusher& CDmaPusher() const; | ||
| 198 | |||
| 199 | /// Returns a reference to the underlying renderer. | 183 | /// Returns a reference to the underlying renderer. |
| 200 | [[nodiscard]] VideoCore::RendererBase& Renderer(); | 184 | [[nodiscard]] VideoCore::RendererBase& Renderer(); |
| 201 | 185 | ||
diff --git a/src/video_core/macro/macro.cpp b/src/video_core/macro/macro.cpp index d7fabe605..0aeda4ce8 100644 --- a/src/video_core/macro/macro.cpp +++ b/src/video_core/macro/macro.cpp | |||
| @@ -2,12 +2,13 @@ | |||
| 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 | #include <cstring> | ||
| 5 | #include <optional> | 6 | #include <optional> |
| 7 | |||
| 6 | #include <boost/container_hash/hash.hpp> | 8 | #include <boost/container_hash/hash.hpp> |
| 9 | |||
| 7 | #include "common/assert.h" | 10 | #include "common/assert.h" |
| 8 | #include "common/logging/log.h" | ||
| 9 | #include "common/settings.h" | 11 | #include "common/settings.h" |
| 10 | #include "video_core/engines/maxwell_3d.h" | ||
| 11 | #include "video_core/macro/macro.h" | 12 | #include "video_core/macro/macro.h" |
| 12 | #include "video_core/macro/macro_hle.h" | 13 | #include "video_core/macro/macro_hle.h" |
| 13 | #include "video_core/macro/macro_interpreter.h" | 14 | #include "video_core/macro/macro_interpreter.h" |
| @@ -24,8 +25,7 @@ void MacroEngine::AddCode(u32 method, u32 data) { | |||
| 24 | uploaded_macro_code[method].push_back(data); | 25 | uploaded_macro_code[method].push_back(data); |
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | void MacroEngine::Execute(Engines::Maxwell3D& maxwell3d, u32 method, | 28 | void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) { |
| 28 | const std::vector<u32>& parameters) { | ||
| 29 | auto compiled_macro = macro_cache.find(method); | 29 | auto compiled_macro = macro_cache.find(method); |
| 30 | if (compiled_macro != macro_cache.end()) { | 30 | if (compiled_macro != macro_cache.end()) { |
| 31 | const auto& cache_info = compiled_macro->second; | 31 | const auto& cache_info = compiled_macro->second; |
| @@ -66,10 +66,9 @@ void MacroEngine::Execute(Engines::Maxwell3D& maxwell3d, u32 method, | |||
| 66 | cache_info.lle_program = Compile(code); | 66 | cache_info.lle_program = Compile(code); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | auto hle_program = hle_macros->GetHLEProgram(cache_info.hash); | 69 | if (auto hle_program = hle_macros->GetHLEProgram(cache_info.hash)) { |
| 70 | if (hle_program.has_value()) { | ||
| 71 | cache_info.has_hle_program = true; | 70 | cache_info.has_hle_program = true; |
| 72 | cache_info.hle_program = std::move(hle_program.value()); | 71 | cache_info.hle_program = std::move(hle_program); |
| 73 | cache_info.hle_program->Execute(parameters, method); | 72 | cache_info.hle_program->Execute(parameters, method); |
| 74 | } else { | 73 | } else { |
| 75 | cache_info.lle_program->Execute(parameters, method); | 74 | cache_info.lle_program->Execute(parameters, method); |
diff --git a/src/video_core/macro/macro.h b/src/video_core/macro/macro.h index 31ee3440a..7aaa49286 100644 --- a/src/video_core/macro/macro.h +++ b/src/video_core/macro/macro.h | |||
| @@ -119,7 +119,7 @@ public: | |||
| 119 | void AddCode(u32 method, u32 data); | 119 | void AddCode(u32 method, u32 data); |
| 120 | 120 | ||
| 121 | // Compiles the macro if its not in the cache, and executes the compiled macro | 121 | // Compiles the macro if its not in the cache, and executes the compiled macro |
| 122 | void Execute(Engines::Maxwell3D& maxwell3d, u32 method, const std::vector<u32>& parameters); | 122 | void Execute(u32 method, const std::vector<u32>& parameters); |
| 123 | 123 | ||
| 124 | protected: | 124 | protected: |
| 125 | virtual std::unique_ptr<CachedMacro> Compile(const std::vector<u32>& code) = 0; | 125 | virtual std::unique_ptr<CachedMacro> Compile(const std::vector<u32>& code) = 0; |
diff --git a/src/video_core/macro/macro_hle.cpp b/src/video_core/macro/macro_hle.cpp index 70ac7c620..900ad23c9 100644 --- a/src/video_core/macro/macro_hle.cpp +++ b/src/video_core/macro/macro_hle.cpp | |||
| @@ -5,12 +5,15 @@ | |||
| 5 | #include <array> | 5 | #include <array> |
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include "video_core/engines/maxwell_3d.h" | 7 | #include "video_core/engines/maxwell_3d.h" |
| 8 | #include "video_core/macro/macro.h" | ||
| 8 | #include "video_core/macro/macro_hle.h" | 9 | #include "video_core/macro/macro_hle.h" |
| 9 | #include "video_core/rasterizer_interface.h" | 10 | #include "video_core/rasterizer_interface.h" |
| 10 | 11 | ||
| 11 | namespace Tegra { | 12 | namespace Tegra { |
| 12 | |||
| 13 | namespace { | 13 | namespace { |
| 14 | |||
| 15 | using HLEFunction = void (*)(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters); | ||
| 16 | |||
| 14 | // HLE'd functions | 17 | // HLE'd functions |
| 15 | void HLE_771BB18C62444DA0(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) { | 18 | void HLE_771BB18C62444DA0(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) { |
| 16 | const u32 instance_count = parameters[2] & maxwell3d.GetRegisterValue(0xD1B); | 19 | const u32 instance_count = parameters[2] & maxwell3d.GetRegisterValue(0xD1B); |
| @@ -77,7 +80,6 @@ void HLE_0217920100488FF7(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& | |||
| 77 | maxwell3d.CallMethodFromMME(0x8e5, 0x0); | 80 | maxwell3d.CallMethodFromMME(0x8e5, 0x0); |
| 78 | maxwell3d.mme_draw.current_mode = Engines::Maxwell3D::MMEDrawMode::Undefined; | 81 | maxwell3d.mme_draw.current_mode = Engines::Maxwell3D::MMEDrawMode::Undefined; |
| 79 | } | 82 | } |
| 80 | } // Anonymous namespace | ||
| 81 | 83 | ||
| 82 | constexpr std::array<std::pair<u64, HLEFunction>, 3> hle_funcs{{ | 84 | constexpr std::array<std::pair<u64, HLEFunction>, 3> hle_funcs{{ |
| 83 | {0x771BB18C62444DA0, &HLE_771BB18C62444DA0}, | 85 | {0x771BB18C62444DA0, &HLE_771BB18C62444DA0}, |
| @@ -85,25 +87,31 @@ constexpr std::array<std::pair<u64, HLEFunction>, 3> hle_funcs{{ | |||
| 85 | {0x0217920100488FF7, &HLE_0217920100488FF7}, | 87 | {0x0217920100488FF7, &HLE_0217920100488FF7}, |
| 86 | }}; | 88 | }}; |
| 87 | 89 | ||
| 90 | class HLEMacroImpl final : public CachedMacro { | ||
| 91 | public: | ||
| 92 | explicit HLEMacroImpl(Engines::Maxwell3D& maxwell3d_, HLEFunction func_) | ||
| 93 | : maxwell3d{maxwell3d_}, func{func_} {} | ||
| 94 | |||
| 95 | void Execute(const std::vector<u32>& parameters, u32 method) override { | ||
| 96 | func(maxwell3d, parameters); | ||
| 97 | } | ||
| 98 | |||
| 99 | private: | ||
| 100 | Engines::Maxwell3D& maxwell3d; | ||
| 101 | HLEFunction func; | ||
| 102 | }; | ||
| 103 | } // Anonymous namespace | ||
| 104 | |||
| 88 | HLEMacro::HLEMacro(Engines::Maxwell3D& maxwell3d_) : maxwell3d{maxwell3d_} {} | 105 | HLEMacro::HLEMacro(Engines::Maxwell3D& maxwell3d_) : maxwell3d{maxwell3d_} {} |
| 89 | HLEMacro::~HLEMacro() = default; | 106 | HLEMacro::~HLEMacro() = default; |
| 90 | 107 | ||
| 91 | std::optional<std::unique_ptr<CachedMacro>> HLEMacro::GetHLEProgram(u64 hash) const { | 108 | std::unique_ptr<CachedMacro> HLEMacro::GetHLEProgram(u64 hash) const { |
| 92 | const auto it = std::find_if(hle_funcs.cbegin(), hle_funcs.cend(), | 109 | const auto it = std::find_if(hle_funcs.cbegin(), hle_funcs.cend(), |
| 93 | [hash](const auto& pair) { return pair.first == hash; }); | 110 | [hash](const auto& pair) { return pair.first == hash; }); |
| 94 | if (it == hle_funcs.end()) { | 111 | if (it == hle_funcs.end()) { |
| 95 | return std::nullopt; | 112 | return nullptr; |
| 96 | } | 113 | } |
| 97 | return std::make_unique<HLEMacroImpl>(maxwell3d, it->second); | 114 | return std::make_unique<HLEMacroImpl>(maxwell3d, it->second); |
| 98 | } | 115 | } |
| 99 | 116 | ||
| 100 | HLEMacroImpl::~HLEMacroImpl() = default; | ||
| 101 | |||
| 102 | HLEMacroImpl::HLEMacroImpl(Engines::Maxwell3D& maxwell3d_, HLEFunction func_) | ||
| 103 | : maxwell3d{maxwell3d_}, func{func_} {} | ||
| 104 | |||
| 105 | void HLEMacroImpl::Execute(const std::vector<u32>& parameters, u32 method) { | ||
| 106 | func(maxwell3d, parameters); | ||
| 107 | } | ||
| 108 | |||
| 109 | } // namespace Tegra | 117 | } // namespace Tegra |
diff --git a/src/video_core/macro/macro_hle.h b/src/video_core/macro/macro_hle.h index cb3bd1600..b86ba84a1 100644 --- a/src/video_core/macro/macro_hle.h +++ b/src/video_core/macro/macro_hle.h | |||
| @@ -5,10 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <optional> | ||
| 9 | #include <vector> | ||
| 10 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 11 | #include "video_core/macro/macro.h" | ||
| 12 | 9 | ||
| 13 | namespace Tegra { | 10 | namespace Tegra { |
| 14 | 11 | ||
| @@ -16,29 +13,17 @@ namespace Engines { | |||
| 16 | class Maxwell3D; | 13 | class Maxwell3D; |
| 17 | } | 14 | } |
| 18 | 15 | ||
| 19 | using HLEFunction = void (*)(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters); | ||
| 20 | |||
| 21 | class HLEMacro { | 16 | class HLEMacro { |
| 22 | public: | 17 | public: |
| 23 | explicit HLEMacro(Engines::Maxwell3D& maxwell3d_); | 18 | explicit HLEMacro(Engines::Maxwell3D& maxwell3d_); |
| 24 | ~HLEMacro(); | 19 | ~HLEMacro(); |
| 25 | 20 | ||
| 26 | std::optional<std::unique_ptr<CachedMacro>> GetHLEProgram(u64 hash) const; | 21 | // Allocates and returns a cached macro if the hash matches a known function. |
| 27 | 22 | // Returns nullptr otherwise. | |
| 28 | private: | 23 | [[nodiscard]] std::unique_ptr<CachedMacro> GetHLEProgram(u64 hash) const; |
| 29 | Engines::Maxwell3D& maxwell3d; | ||
| 30 | }; | ||
| 31 | |||
| 32 | class HLEMacroImpl : public CachedMacro { | ||
| 33 | public: | ||
| 34 | explicit HLEMacroImpl(Engines::Maxwell3D& maxwell3d, HLEFunction func); | ||
| 35 | ~HLEMacroImpl(); | ||
| 36 | |||
| 37 | void Execute(const std::vector<u32>& parameters, u32 method) override; | ||
| 38 | 24 | ||
| 39 | private: | 25 | private: |
| 40 | Engines::Maxwell3D& maxwell3d; | 26 | Engines::Maxwell3D& maxwell3d; |
| 41 | HLEFunction func; | ||
| 42 | }; | 27 | }; |
| 43 | 28 | ||
| 44 | } // namespace Tegra | 29 | } // namespace Tegra |
diff --git a/src/video_core/macro/macro_interpreter.cpp b/src/video_core/macro/macro_interpreter.cpp index 8da26fd59..fba755448 100644 --- a/src/video_core/macro/macro_interpreter.cpp +++ b/src/video_core/macro/macro_interpreter.cpp | |||
| @@ -2,6 +2,9 @@ | |||
| 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 | #include <array> | ||
| 6 | #include <optional> | ||
| 7 | |||
| 5 | #include "common/assert.h" | 8 | #include "common/assert.h" |
| 6 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 7 | #include "common/microprofile.h" | 10 | #include "common/microprofile.h" |
| @@ -11,16 +14,81 @@ | |||
| 11 | MICROPROFILE_DEFINE(MacroInterp, "GPU", "Execute macro interpreter", MP_RGB(128, 128, 192)); | 14 | MICROPROFILE_DEFINE(MacroInterp, "GPU", "Execute macro interpreter", MP_RGB(128, 128, 192)); |
| 12 | 15 | ||
| 13 | namespace Tegra { | 16 | namespace Tegra { |
| 14 | MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d_) | 17 | namespace { |
| 15 | : MacroEngine{maxwell3d_}, maxwell3d{maxwell3d_} {} | 18 | class MacroInterpreterImpl final : public CachedMacro { |
| 19 | public: | ||
| 20 | explicit MacroInterpreterImpl(Engines::Maxwell3D& maxwell3d_, const std::vector<u32>& code_) | ||
| 21 | : maxwell3d{maxwell3d_}, code{code_} {} | ||
| 16 | 22 | ||
| 17 | std::unique_ptr<CachedMacro> MacroInterpreter::Compile(const std::vector<u32>& code) { | 23 | void Execute(const std::vector<u32>& params, u32 method) override; |
| 18 | return std::make_unique<MacroInterpreterImpl>(maxwell3d, code); | 24 | |
| 19 | } | 25 | private: |
| 26 | /// Resets the execution engine state, zeroing registers, etc. | ||
| 27 | void Reset(); | ||
| 28 | |||
| 29 | /** | ||
| 30 | * Executes a single macro instruction located at the current program counter. Returns whether | ||
| 31 | * the interpreter should keep running. | ||
| 32 | * | ||
| 33 | * @param is_delay_slot Whether the current step is being executed due to a delay slot in a | ||
| 34 | * previous instruction. | ||
| 35 | */ | ||
| 36 | bool Step(bool is_delay_slot); | ||
| 37 | |||
| 38 | /// Calculates the result of an ALU operation. src_a OP src_b; | ||
| 39 | u32 GetALUResult(Macro::ALUOperation operation, u32 src_a, u32 src_b); | ||
| 40 | |||
| 41 | /// Performs the result operation on the input result and stores it in the specified register | ||
| 42 | /// (if necessary). | ||
| 43 | void ProcessResult(Macro::ResultOperation operation, u32 reg, u32 result); | ||
| 44 | |||
| 45 | /// Evaluates the branch condition and returns whether the branch should be taken or not. | ||
| 46 | bool EvaluateBranchCondition(Macro::BranchCondition cond, u32 value) const; | ||
| 47 | |||
| 48 | /// Reads an opcode at the current program counter location. | ||
| 49 | Macro::Opcode GetOpcode() const; | ||
| 50 | |||
| 51 | /// Returns the specified register's value. Register 0 is hardcoded to always return 0. | ||
| 52 | u32 GetRegister(u32 register_id) const; | ||
| 53 | |||
| 54 | /// Sets the register to the input value. | ||
| 55 | void SetRegister(u32 register_id, u32 value); | ||
| 56 | |||
| 57 | /// Sets the method address to use for the next Send instruction. | ||
| 58 | void SetMethodAddress(u32 address); | ||
| 20 | 59 | ||
| 21 | MacroInterpreterImpl::MacroInterpreterImpl(Engines::Maxwell3D& maxwell3d_, | 60 | /// Calls a GPU Engine method with the input parameter. |
| 22 | const std::vector<u32>& code_) | 61 | void Send(u32 value); |
| 23 | : maxwell3d{maxwell3d_}, code{code_} {} | 62 | |
| 63 | /// Reads a GPU register located at the method address. | ||
| 64 | u32 Read(u32 method) const; | ||
| 65 | |||
| 66 | /// Returns the next parameter in the parameter queue. | ||
| 67 | u32 FetchParameter(); | ||
| 68 | |||
| 69 | Engines::Maxwell3D& maxwell3d; | ||
| 70 | |||
| 71 | /// Current program counter | ||
| 72 | u32 pc{}; | ||
| 73 | /// Program counter to execute at after the delay slot is executed. | ||
| 74 | std::optional<u32> delayed_pc; | ||
| 75 | |||
| 76 | /// General purpose macro registers. | ||
| 77 | std::array<u32, Macro::NUM_MACRO_REGISTERS> registers = {}; | ||
| 78 | |||
| 79 | /// Method address to use for the next Send instruction. | ||
| 80 | Macro::MethodAddress method_address = {}; | ||
| 81 | |||
| 82 | /// Input parameters of the current macro. | ||
| 83 | std::unique_ptr<u32[]> parameters; | ||
| 84 | std::size_t num_parameters = 0; | ||
| 85 | std::size_t parameters_capacity = 0; | ||
| 86 | /// Index of the next parameter that will be fetched by the 'parm' instruction. | ||
| 87 | u32 next_parameter_index = 0; | ||
| 88 | |||
| 89 | bool carry_flag = false; | ||
| 90 | const std::vector<u32>& code; | ||
| 91 | }; | ||
| 24 | 92 | ||
| 25 | void MacroInterpreterImpl::Execute(const std::vector<u32>& params, u32 method) { | 93 | void MacroInterpreterImpl::Execute(const std::vector<u32>& params, u32 method) { |
| 26 | MICROPROFILE_SCOPE(MacroInterp); | 94 | MICROPROFILE_SCOPE(MacroInterp); |
| @@ -283,5 +351,13 @@ u32 MacroInterpreterImpl::FetchParameter() { | |||
| 283 | ASSERT(next_parameter_index < num_parameters); | 351 | ASSERT(next_parameter_index < num_parameters); |
| 284 | return parameters[next_parameter_index++]; | 352 | return parameters[next_parameter_index++]; |
| 285 | } | 353 | } |
| 354 | } // Anonymous namespace | ||
| 355 | |||
| 356 | MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d_) | ||
| 357 | : MacroEngine{maxwell3d_}, maxwell3d{maxwell3d_} {} | ||
| 358 | |||
| 359 | std::unique_ptr<CachedMacro> MacroInterpreter::Compile(const std::vector<u32>& code) { | ||
| 360 | return std::make_unique<MacroInterpreterImpl>(maxwell3d, code); | ||
| 361 | } | ||
| 286 | 362 | ||
| 287 | } // namespace Tegra | 363 | } // namespace Tegra |
diff --git a/src/video_core/macro/macro_interpreter.h b/src/video_core/macro/macro_interpreter.h index d50c619ce..8a9648e46 100644 --- a/src/video_core/macro/macro_interpreter.h +++ b/src/video_core/macro/macro_interpreter.h | |||
| @@ -3,10 +3,9 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | #include <array> | 6 | |
| 7 | #include <optional> | ||
| 8 | #include <vector> | 7 | #include <vector> |
| 9 | #include "common/bit_field.h" | 8 | |
| 10 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 11 | #include "video_core/macro/macro.h" | 10 | #include "video_core/macro/macro.h" |
| 12 | 11 | ||
| @@ -26,77 +25,4 @@ private: | |||
| 26 | Engines::Maxwell3D& maxwell3d; | 25 | Engines::Maxwell3D& maxwell3d; |
| 27 | }; | 26 | }; |
| 28 | 27 | ||
| 29 | class MacroInterpreterImpl : public CachedMacro { | ||
| 30 | public: | ||
| 31 | explicit MacroInterpreterImpl(Engines::Maxwell3D& maxwell3d_, const std::vector<u32>& code_); | ||
| 32 | void Execute(const std::vector<u32>& params, u32 method) override; | ||
| 33 | |||
| 34 | private: | ||
| 35 | /// Resets the execution engine state, zeroing registers, etc. | ||
| 36 | void Reset(); | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Executes a single macro instruction located at the current program counter. Returns whether | ||
| 40 | * the interpreter should keep running. | ||
| 41 | * | ||
| 42 | * @param is_delay_slot Whether the current step is being executed due to a delay slot in a | ||
| 43 | * previous instruction. | ||
| 44 | */ | ||
| 45 | bool Step(bool is_delay_slot); | ||
| 46 | |||
| 47 | /// Calculates the result of an ALU operation. src_a OP src_b; | ||
| 48 | u32 GetALUResult(Macro::ALUOperation operation, u32 src_a, u32 src_b); | ||
| 49 | |||
| 50 | /// Performs the result operation on the input result and stores it in the specified register | ||
| 51 | /// (if necessary). | ||
| 52 | void ProcessResult(Macro::ResultOperation operation, u32 reg, u32 result); | ||
| 53 | |||
| 54 | /// Evaluates the branch condition and returns whether the branch should be taken or not. | ||
| 55 | bool EvaluateBranchCondition(Macro::BranchCondition cond, u32 value) const; | ||
| 56 | |||
| 57 | /// Reads an opcode at the current program counter location. | ||
| 58 | Macro::Opcode GetOpcode() const; | ||
| 59 | |||
| 60 | /// Returns the specified register's value. Register 0 is hardcoded to always return 0. | ||
| 61 | u32 GetRegister(u32 register_id) const; | ||
| 62 | |||
| 63 | /// Sets the register to the input value. | ||
| 64 | void SetRegister(u32 register_id, u32 value); | ||
| 65 | |||
| 66 | /// Sets the method address to use for the next Send instruction. | ||
| 67 | void SetMethodAddress(u32 address); | ||
| 68 | |||
| 69 | /// Calls a GPU Engine method with the input parameter. | ||
| 70 | void Send(u32 value); | ||
| 71 | |||
| 72 | /// Reads a GPU register located at the method address. | ||
| 73 | u32 Read(u32 method) const; | ||
| 74 | |||
| 75 | /// Returns the next parameter in the parameter queue. | ||
| 76 | u32 FetchParameter(); | ||
| 77 | |||
| 78 | Engines::Maxwell3D& maxwell3d; | ||
| 79 | |||
| 80 | /// Current program counter | ||
| 81 | u32 pc; | ||
| 82 | /// Program counter to execute at after the delay slot is executed. | ||
| 83 | std::optional<u32> delayed_pc; | ||
| 84 | |||
| 85 | /// General purpose macro registers. | ||
| 86 | std::array<u32, Macro::NUM_MACRO_REGISTERS> registers = {}; | ||
| 87 | |||
| 88 | /// Method address to use for the next Send instruction. | ||
| 89 | Macro::MethodAddress method_address = {}; | ||
| 90 | |||
| 91 | /// Input parameters of the current macro. | ||
| 92 | std::unique_ptr<u32[]> parameters; | ||
| 93 | std::size_t num_parameters = 0; | ||
| 94 | std::size_t parameters_capacity = 0; | ||
| 95 | /// Index of the next parameter that will be fetched by the 'parm' instruction. | ||
| 96 | u32 next_parameter_index = 0; | ||
| 97 | |||
| 98 | bool carry_flag = false; | ||
| 99 | const std::vector<u32>& code; | ||
| 100 | }; | ||
| 101 | |||
| 102 | } // namespace Tegra | 28 | } // namespace Tegra |
diff --git a/src/video_core/macro/macro_jit_x64.cpp b/src/video_core/macro/macro_jit_x64.cpp index c6b2b2109..924c9fe5c 100644 --- a/src/video_core/macro/macro_jit_x64.cpp +++ b/src/video_core/macro/macro_jit_x64.cpp | |||
| @@ -2,9 +2,17 @@ | |||
| 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 | #include <array> | ||
| 6 | #include <bitset> | ||
| 7 | #include <optional> | ||
| 8 | |||
| 9 | #include <xbyak/xbyak.h> | ||
| 10 | |||
| 5 | #include "common/assert.h" | 11 | #include "common/assert.h" |
| 12 | #include "common/bit_field.h" | ||
| 6 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 7 | #include "common/microprofile.h" | 14 | #include "common/microprofile.h" |
| 15 | #include "common/x64/xbyak_abi.h" | ||
| 8 | #include "common/x64/xbyak_util.h" | 16 | #include "common/x64/xbyak_util.h" |
| 9 | #include "video_core/engines/maxwell_3d.h" | 17 | #include "video_core/engines/maxwell_3d.h" |
| 10 | #include "video_core/macro/macro_interpreter.h" | 18 | #include "video_core/macro/macro_interpreter.h" |
| @@ -14,13 +22,14 @@ MICROPROFILE_DEFINE(MacroJitCompile, "GPU", "Compile macro JIT", MP_RGB(173, 255 | |||
| 14 | MICROPROFILE_DEFINE(MacroJitExecute, "GPU", "Execute macro JIT", MP_RGB(255, 255, 0)); | 22 | MICROPROFILE_DEFINE(MacroJitExecute, "GPU", "Execute macro JIT", MP_RGB(255, 255, 0)); |
| 15 | 23 | ||
| 16 | namespace Tegra { | 24 | namespace Tegra { |
| 25 | namespace { | ||
| 17 | constexpr Xbyak::Reg64 STATE = Xbyak::util::rbx; | 26 | constexpr Xbyak::Reg64 STATE = Xbyak::util::rbx; |
| 18 | constexpr Xbyak::Reg32 RESULT = Xbyak::util::ebp; | 27 | constexpr Xbyak::Reg32 RESULT = Xbyak::util::ebp; |
| 19 | constexpr Xbyak::Reg64 PARAMETERS = Xbyak::util::r12; | 28 | constexpr Xbyak::Reg64 PARAMETERS = Xbyak::util::r12; |
| 20 | constexpr Xbyak::Reg32 METHOD_ADDRESS = Xbyak::util::r14d; | 29 | constexpr Xbyak::Reg32 METHOD_ADDRESS = Xbyak::util::r14d; |
| 21 | constexpr Xbyak::Reg64 BRANCH_HOLDER = Xbyak::util::r15; | 30 | constexpr Xbyak::Reg64 BRANCH_HOLDER = Xbyak::util::r15; |
| 22 | 31 | ||
| 23 | static const std::bitset<32> PERSISTENT_REGISTERS = Common::X64::BuildRegSet({ | 32 | const std::bitset<32> PERSISTENT_REGISTERS = Common::X64::BuildRegSet({ |
| 24 | STATE, | 33 | STATE, |
| 25 | RESULT, | 34 | RESULT, |
| 26 | PARAMETERS, | 35 | PARAMETERS, |
| @@ -28,19 +37,75 @@ static const std::bitset<32> PERSISTENT_REGISTERS = Common::X64::BuildRegSet({ | |||
| 28 | BRANCH_HOLDER, | 37 | BRANCH_HOLDER, |
| 29 | }); | 38 | }); |
| 30 | 39 | ||
| 31 | MacroJITx64::MacroJITx64(Engines::Maxwell3D& maxwell3d_) | 40 | // Arbitrarily chosen based on current booting games. |
| 32 | : MacroEngine{maxwell3d_}, maxwell3d{maxwell3d_} {} | 41 | constexpr size_t MAX_CODE_SIZE = 0x10000; |
| 33 | 42 | ||
| 34 | std::unique_ptr<CachedMacro> MacroJITx64::Compile(const std::vector<u32>& code) { | 43 | std::bitset<32> PersistentCallerSavedRegs() { |
| 35 | return std::make_unique<MacroJITx64Impl>(maxwell3d, code); | 44 | return PERSISTENT_REGISTERS & Common::X64::ABI_ALL_CALLER_SAVED; |
| 36 | } | 45 | } |
| 37 | 46 | ||
| 38 | MacroJITx64Impl::MacroJITx64Impl(Engines::Maxwell3D& maxwell3d_, const std::vector<u32>& code_) | 47 | class MacroJITx64Impl final : public Xbyak::CodeGenerator, public CachedMacro { |
| 39 | : CodeGenerator{MAX_CODE_SIZE}, code{code_}, maxwell3d{maxwell3d_} { | 48 | public: |
| 40 | Compile(); | 49 | explicit MacroJITx64Impl(Engines::Maxwell3D& maxwell3d_, const std::vector<u32>& code_) |
| 41 | } | 50 | : CodeGenerator{MAX_CODE_SIZE}, code{code_}, maxwell3d{maxwell3d_} { |
| 51 | Compile(); | ||
| 52 | } | ||
| 53 | |||
| 54 | void Execute(const std::vector<u32>& parameters, u32 method) override; | ||
| 55 | |||
| 56 | void Compile_ALU(Macro::Opcode opcode); | ||
| 57 | void Compile_AddImmediate(Macro::Opcode opcode); | ||
| 58 | void Compile_ExtractInsert(Macro::Opcode opcode); | ||
| 59 | void Compile_ExtractShiftLeftImmediate(Macro::Opcode opcode); | ||
| 60 | void Compile_ExtractShiftLeftRegister(Macro::Opcode opcode); | ||
| 61 | void Compile_Read(Macro::Opcode opcode); | ||
| 62 | void Compile_Branch(Macro::Opcode opcode); | ||
| 63 | |||
| 64 | private: | ||
| 65 | void Optimizer_ScanFlags(); | ||
| 66 | |||
| 67 | void Compile(); | ||
| 68 | bool Compile_NextInstruction(); | ||
| 69 | |||
| 70 | Xbyak::Reg32 Compile_FetchParameter(); | ||
| 71 | Xbyak::Reg32 Compile_GetRegister(u32 index, Xbyak::Reg32 dst); | ||
| 72 | |||
| 73 | void Compile_ProcessResult(Macro::ResultOperation operation, u32 reg); | ||
| 74 | void Compile_Send(Xbyak::Reg32 value); | ||
| 42 | 75 | ||
| 43 | MacroJITx64Impl::~MacroJITx64Impl() = default; | 76 | Macro::Opcode GetOpCode() const; |
| 77 | |||
| 78 | struct JITState { | ||
| 79 | Engines::Maxwell3D* maxwell3d{}; | ||
| 80 | std::array<u32, Macro::NUM_MACRO_REGISTERS> registers{}; | ||
| 81 | u32 carry_flag{}; | ||
| 82 | }; | ||
| 83 | static_assert(offsetof(JITState, maxwell3d) == 0, "Maxwell3D is not at 0x0"); | ||
| 84 | using ProgramType = void (*)(JITState*, const u32*); | ||
| 85 | |||
| 86 | struct OptimizerState { | ||
| 87 | bool can_skip_carry{}; | ||
| 88 | bool has_delayed_pc{}; | ||
| 89 | bool zero_reg_skip{}; | ||
| 90 | bool skip_dummy_addimmediate{}; | ||
| 91 | bool optimize_for_method_move{}; | ||
| 92 | bool enable_asserts{}; | ||
| 93 | }; | ||
| 94 | OptimizerState optimizer{}; | ||
| 95 | |||
| 96 | std::optional<Macro::Opcode> next_opcode{}; | ||
| 97 | ProgramType program{nullptr}; | ||
| 98 | |||
| 99 | std::array<Xbyak::Label, MAX_CODE_SIZE> labels; | ||
| 100 | std::array<Xbyak::Label, MAX_CODE_SIZE> delay_skip; | ||
| 101 | Xbyak::Label end_of_code{}; | ||
| 102 | |||
| 103 | bool is_delay_slot{}; | ||
| 104 | u32 pc{}; | ||
| 105 | |||
| 106 | const std::vector<u32>& code; | ||
| 107 | Engines::Maxwell3D& maxwell3d; | ||
| 108 | }; | ||
| 44 | 109 | ||
| 45 | void MacroJITx64Impl::Execute(const std::vector<u32>& parameters, u32 method) { | 110 | void MacroJITx64Impl::Execute(const std::vector<u32>& parameters, u32 method) { |
| 46 | MICROPROFILE_SCOPE(MacroJitExecute); | 111 | MICROPROFILE_SCOPE(MacroJitExecute); |
| @@ -307,11 +372,11 @@ void MacroJITx64Impl::Compile_Read(Macro::Opcode opcode) { | |||
| 307 | Compile_ProcessResult(opcode.result_operation, opcode.dst); | 372 | Compile_ProcessResult(opcode.result_operation, opcode.dst); |
| 308 | } | 373 | } |
| 309 | 374 | ||
| 310 | static void Send(Engines::Maxwell3D* maxwell3d, Macro::MethodAddress method_address, u32 value) { | 375 | void Send(Engines::Maxwell3D* maxwell3d, Macro::MethodAddress method_address, u32 value) { |
| 311 | maxwell3d->CallMethodFromMME(method_address.address, value); | 376 | maxwell3d->CallMethodFromMME(method_address.address, value); |
| 312 | } | 377 | } |
| 313 | 378 | ||
| 314 | void Tegra::MacroJITx64Impl::Compile_Send(Xbyak::Reg32 value) { | 379 | void MacroJITx64Impl::Compile_Send(Xbyak::Reg32 value) { |
| 315 | Common::X64::ABI_PushRegistersAndAdjustStack(*this, PersistentCallerSavedRegs(), 0); | 380 | Common::X64::ABI_PushRegistersAndAdjustStack(*this, PersistentCallerSavedRegs(), 0); |
| 316 | mov(Common::X64::ABI_PARAM1, qword[STATE]); | 381 | mov(Common::X64::ABI_PARAM1, qword[STATE]); |
| 317 | mov(Common::X64::ABI_PARAM2, METHOD_ADDRESS); | 382 | mov(Common::X64::ABI_PARAM2, METHOD_ADDRESS); |
| @@ -338,7 +403,7 @@ void Tegra::MacroJITx64Impl::Compile_Send(Xbyak::Reg32 value) { | |||
| 338 | L(dont_process); | 403 | L(dont_process); |
| 339 | } | 404 | } |
| 340 | 405 | ||
| 341 | void Tegra::MacroJITx64Impl::Compile_Branch(Macro::Opcode opcode) { | 406 | void MacroJITx64Impl::Compile_Branch(Macro::Opcode opcode) { |
| 342 | ASSERT_MSG(!is_delay_slot, "Executing a branch in a delay slot is not valid"); | 407 | ASSERT_MSG(!is_delay_slot, "Executing a branch in a delay slot is not valid"); |
| 343 | const s32 jump_address = | 408 | const s32 jump_address = |
| 344 | static_cast<s32>(pc) + static_cast<s32>(opcode.GetBranchTarget() / sizeof(s32)); | 409 | static_cast<s32>(pc) + static_cast<s32>(opcode.GetBranchTarget() / sizeof(s32)); |
| @@ -392,7 +457,7 @@ void Tegra::MacroJITx64Impl::Compile_Branch(Macro::Opcode opcode) { | |||
| 392 | L(end); | 457 | L(end); |
| 393 | } | 458 | } |
| 394 | 459 | ||
| 395 | void Tegra::MacroJITx64Impl::Optimizer_ScanFlags() { | 460 | void MacroJITx64Impl::Optimizer_ScanFlags() { |
| 396 | optimizer.can_skip_carry = true; | 461 | optimizer.can_skip_carry = true; |
| 397 | optimizer.has_delayed_pc = false; | 462 | optimizer.has_delayed_pc = false; |
| 398 | for (auto raw_op : code) { | 463 | for (auto raw_op : code) { |
| @@ -534,7 +599,7 @@ bool MacroJITx64Impl::Compile_NextInstruction() { | |||
| 534 | return true; | 599 | return true; |
| 535 | } | 600 | } |
| 536 | 601 | ||
| 537 | Xbyak::Reg32 Tegra::MacroJITx64Impl::Compile_FetchParameter() { | 602 | Xbyak::Reg32 MacroJITx64Impl::Compile_FetchParameter() { |
| 538 | mov(eax, dword[PARAMETERS]); | 603 | mov(eax, dword[PARAMETERS]); |
| 539 | add(PARAMETERS, sizeof(u32)); | 604 | add(PARAMETERS, sizeof(u32)); |
| 540 | return eax; | 605 | return eax; |
| @@ -611,9 +676,12 @@ Macro::Opcode MacroJITx64Impl::GetOpCode() const { | |||
| 611 | ASSERT(pc < code.size()); | 676 | ASSERT(pc < code.size()); |
| 612 | return {code[pc]}; | 677 | return {code[pc]}; |
| 613 | } | 678 | } |
| 679 | } // Anonymous namespace | ||
| 614 | 680 | ||
| 615 | std::bitset<32> MacroJITx64Impl::PersistentCallerSavedRegs() const { | 681 | MacroJITx64::MacroJITx64(Engines::Maxwell3D& maxwell3d_) |
| 616 | return PERSISTENT_REGISTERS & Common::X64::ABI_ALL_CALLER_SAVED; | 682 | : MacroEngine{maxwell3d_}, maxwell3d{maxwell3d_} {} |
| 617 | } | ||
| 618 | 683 | ||
| 684 | std::unique_ptr<CachedMacro> MacroJITx64::Compile(const std::vector<u32>& code) { | ||
| 685 | return std::make_unique<MacroJITx64Impl>(maxwell3d, code); | ||
| 686 | } | ||
| 619 | } // namespace Tegra | 687 | } // namespace Tegra |
diff --git a/src/video_core/macro/macro_jit_x64.h b/src/video_core/macro/macro_jit_x64.h index d03d480b4..773b037ae 100644 --- a/src/video_core/macro/macro_jit_x64.h +++ b/src/video_core/macro/macro_jit_x64.h | |||
| @@ -4,12 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include <bitset> | ||
| 9 | #include <xbyak/xbyak.h> | ||
| 10 | #include "common/bit_field.h" | ||
| 11 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 12 | #include "common/x64/xbyak_abi.h" | ||
| 13 | #include "video_core/macro/macro.h" | 8 | #include "video_core/macro/macro.h" |
| 14 | 9 | ||
| 15 | namespace Tegra { | 10 | namespace Tegra { |
| @@ -18,9 +13,6 @@ namespace Engines { | |||
| 18 | class Maxwell3D; | 13 | class Maxwell3D; |
| 19 | } | 14 | } |
| 20 | 15 | ||
| 21 | /// MAX_CODE_SIZE is arbitrarily chosen based on current booting games | ||
| 22 | constexpr size_t MAX_CODE_SIZE = 0x10000; | ||
| 23 | |||
| 24 | class MacroJITx64 final : public MacroEngine { | 16 | class MacroJITx64 final : public MacroEngine { |
| 25 | public: | 17 | public: |
| 26 | explicit MacroJITx64(Engines::Maxwell3D& maxwell3d_); | 18 | explicit MacroJITx64(Engines::Maxwell3D& maxwell3d_); |
| @@ -32,67 +24,4 @@ private: | |||
| 32 | Engines::Maxwell3D& maxwell3d; | 24 | Engines::Maxwell3D& maxwell3d; |
| 33 | }; | 25 | }; |
| 34 | 26 | ||
| 35 | class MacroJITx64Impl : public Xbyak::CodeGenerator, public CachedMacro { | ||
| 36 | public: | ||
| 37 | explicit MacroJITx64Impl(Engines::Maxwell3D& maxwell3d_, const std::vector<u32>& code_); | ||
| 38 | ~MacroJITx64Impl(); | ||
| 39 | |||
| 40 | void Execute(const std::vector<u32>& parameters, u32 method) override; | ||
| 41 | |||
| 42 | void Compile_ALU(Macro::Opcode opcode); | ||
| 43 | void Compile_AddImmediate(Macro::Opcode opcode); | ||
| 44 | void Compile_ExtractInsert(Macro::Opcode opcode); | ||
| 45 | void Compile_ExtractShiftLeftImmediate(Macro::Opcode opcode); | ||
| 46 | void Compile_ExtractShiftLeftRegister(Macro::Opcode opcode); | ||
| 47 | void Compile_Read(Macro::Opcode opcode); | ||
| 48 | void Compile_Branch(Macro::Opcode opcode); | ||
| 49 | |||
| 50 | private: | ||
| 51 | void Optimizer_ScanFlags(); | ||
| 52 | |||
| 53 | void Compile(); | ||
| 54 | bool Compile_NextInstruction(); | ||
| 55 | |||
| 56 | Xbyak::Reg32 Compile_FetchParameter(); | ||
| 57 | Xbyak::Reg32 Compile_GetRegister(u32 index, Xbyak::Reg32 dst); | ||
| 58 | |||
| 59 | void Compile_ProcessResult(Macro::ResultOperation operation, u32 reg); | ||
| 60 | void Compile_Send(Xbyak::Reg32 value); | ||
| 61 | |||
| 62 | Macro::Opcode GetOpCode() const; | ||
| 63 | std::bitset<32> PersistentCallerSavedRegs() const; | ||
| 64 | |||
| 65 | struct JITState { | ||
| 66 | Engines::Maxwell3D* maxwell3d{}; | ||
| 67 | std::array<u32, Macro::NUM_MACRO_REGISTERS> registers{}; | ||
| 68 | u32 carry_flag{}; | ||
| 69 | }; | ||
| 70 | static_assert(offsetof(JITState, maxwell3d) == 0, "Maxwell3D is not at 0x0"); | ||
| 71 | using ProgramType = void (*)(JITState*, const u32*); | ||
| 72 | |||
| 73 | struct OptimizerState { | ||
| 74 | bool can_skip_carry{}; | ||
| 75 | bool has_delayed_pc{}; | ||
| 76 | bool zero_reg_skip{}; | ||
| 77 | bool skip_dummy_addimmediate{}; | ||
| 78 | bool optimize_for_method_move{}; | ||
| 79 | bool enable_asserts{}; | ||
| 80 | }; | ||
| 81 | OptimizerState optimizer{}; | ||
| 82 | |||
| 83 | std::optional<Macro::Opcode> next_opcode{}; | ||
| 84 | ProgramType program{nullptr}; | ||
| 85 | |||
| 86 | std::array<Xbyak::Label, MAX_CODE_SIZE> labels; | ||
| 87 | std::array<Xbyak::Label, MAX_CODE_SIZE> delay_skip; | ||
| 88 | Xbyak::Label end_of_code{}; | ||
| 89 | |||
| 90 | bool is_delay_slot{}; | ||
| 91 | u32 pc{}; | ||
| 92 | std::optional<u32> delayed_pc; | ||
| 93 | |||
| 94 | const std::vector<u32>& code; | ||
| 95 | Engines::Maxwell3D& maxwell3d; | ||
| 96 | }; | ||
| 97 | |||
| 98 | } // namespace Tegra | 27 | } // namespace Tegra |
diff --git a/src/video_core/renderer_vulkan/vk_fsr.cpp b/src/video_core/renderer_vulkan/vk_fsr.cpp index 73629d229..b630090e8 100644 --- a/src/video_core/renderer_vulkan/vk_fsr.cpp +++ b/src/video_core/renderer_vulkan/vk_fsr.cpp | |||
| @@ -214,7 +214,7 @@ VkImageView FSR::Draw(VKScheduler& scheduler, size_t image_index, VkImageView im | |||
| 214 | 214 | ||
| 215 | { | 215 | { |
| 216 | VkImageMemoryBarrier fsr_write_barrier = base_barrier; | 216 | VkImageMemoryBarrier fsr_write_barrier = base_barrier; |
| 217 | fsr_write_barrier.image = *images[image_index], | 217 | fsr_write_barrier.image = *images[image_index]; |
| 218 | fsr_write_barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; | 218 | fsr_write_barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 219 | 219 | ||
| 220 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | 220 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 8c370ff91..2c8c10c50 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -65,18 +65,18 @@ const std::array<int, 2> Config::default_stick_mod = { | |||
| 65 | // This must be in alphabetical order according to action name as it must have the same order as | 65 | // This must be in alphabetical order according to action name as it must have the same order as |
| 66 | // UISetting::values.shortcuts, which is alphabetically ordered. | 66 | // UISetting::values.shortcuts, which is alphabetically ordered. |
| 67 | // clang-format off | 67 | // clang-format off |
| 68 | const std::array<UISettings::Shortcut, 21> Config::default_hotkeys{{ | 68 | const std::array<UISettings::Shortcut, 20> Config::default_hotkeys{{ |
| 69 | {QStringLiteral("Audio Mute/Unmute"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), QStringLiteral("Home+Dpad_Right"), Qt::WindowShortcut}}, | ||
| 70 | {QStringLiteral("Audio Volume Down"), QStringLiteral("Main Window"), {QStringLiteral("-"), QStringLiteral("Home+Dpad_Down"), Qt::ApplicationShortcut}}, | ||
| 71 | {QStringLiteral("Audio Volume Up"), QStringLiteral("Main Window"), {QStringLiteral("+"), QStringLiteral("Home+Dpad_Up"), Qt::ApplicationShortcut}}, | ||
| 69 | {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), QStringLiteral("Screenshot"), Qt::WidgetWithChildrenShortcut}}, | 72 | {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), QStringLiteral("Screenshot"), Qt::WidgetWithChildrenShortcut}}, |
| 70 | {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), QStringLiteral("Home+X"), Qt::ApplicationShortcut}}, | 73 | {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), QStringLiteral("Home+X"), Qt::ApplicationShortcut}}, |
| 71 | {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), QStringLiteral("Home+Plus"), Qt::WindowShortcut}}, | 74 | {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), QStringLiteral("Home+Plus"), Qt::WindowShortcut}}, |
| 72 | {QStringLiteral("Decrease Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("-"), QStringLiteral(""), Qt::ApplicationShortcut}}, | ||
| 73 | {QStringLiteral("Exit Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("Esc"), QStringLiteral(""), Qt::WindowShortcut}}, | 75 | {QStringLiteral("Exit Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("Esc"), QStringLiteral(""), Qt::WindowShortcut}}, |
| 74 | {QStringLiteral("Exit yuzu"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Q"), QStringLiteral("Home+Minus"), Qt::WindowShortcut}}, | 76 | {QStringLiteral("Exit yuzu"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Q"), QStringLiteral("Home+Minus"), Qt::WindowShortcut}}, |
| 75 | {QStringLiteral("Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("F11"), QStringLiteral("Home+B"), Qt::WindowShortcut}}, | 77 | {QStringLiteral("Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("F11"), QStringLiteral("Home+B"), Qt::WindowShortcut}}, |
| 76 | {QStringLiteral("Increase Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("+"), QStringLiteral(""), Qt::ApplicationShortcut}}, | ||
| 77 | {QStringLiteral("Load Amiibo"), QStringLiteral("Main Window"), {QStringLiteral("F2"), QStringLiteral("Home+A"), Qt::WidgetWithChildrenShortcut}}, | 78 | {QStringLiteral("Load Amiibo"), QStringLiteral("Main Window"), {QStringLiteral("F2"), QStringLiteral("Home+A"), Qt::WidgetWithChildrenShortcut}}, |
| 78 | {QStringLiteral("Load File"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+O"), QStringLiteral(""), Qt::WidgetWithChildrenShortcut}}, | 79 | {QStringLiteral("Load File"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+O"), QStringLiteral(""), Qt::WidgetWithChildrenShortcut}}, |
| 79 | {QStringLiteral("Mute Audio"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), QStringLiteral(""), Qt::WindowShortcut}}, | ||
| 80 | {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), QStringLiteral(""), Qt::WindowShortcut}}, | 80 | {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), QStringLiteral(""), Qt::WindowShortcut}}, |
| 81 | {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), QStringLiteral(""), Qt::WindowShortcut}}, | 81 | {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), QStringLiteral(""), Qt::WindowShortcut}}, |
| 82 | {QStringLiteral("TAS Start/Stop"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F5"), QStringLiteral(""), Qt::ApplicationShortcut}}, | 82 | {QStringLiteral("TAS Start/Stop"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F5"), QStringLiteral(""), Qt::ApplicationShortcut}}, |
| @@ -85,7 +85,6 @@ const std::array<UISettings::Shortcut, 21> Config::default_hotkeys{{ | |||
| 85 | {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), QStringLiteral(""), Qt::WindowShortcut}}, | 85 | {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), QStringLiteral(""), Qt::WindowShortcut}}, |
| 86 | {QStringLiteral("Toggle Framerate Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+U"), QStringLiteral("Home+Y"), Qt::ApplicationShortcut}}, | 86 | {QStringLiteral("Toggle Framerate Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+U"), QStringLiteral("Home+Y"), Qt::ApplicationShortcut}}, |
| 87 | {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), QStringLiteral(""), Qt::ApplicationShortcut}}, | 87 | {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), QStringLiteral(""), Qt::ApplicationShortcut}}, |
| 88 | {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), QStringLiteral(""), Qt::ApplicationShortcut}}, | ||
| 89 | {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), QStringLiteral(""), Qt::WindowShortcut}}, | 88 | {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), QStringLiteral(""), Qt::WindowShortcut}}, |
| 90 | }}; | 89 | }}; |
| 91 | // clang-format on | 90 | // clang-format on |
| @@ -394,6 +393,8 @@ void Config::ReadControlValues() { | |||
| 394 | ReadGlobalSetting(Settings::values.enable_accurate_vibrations); | 393 | ReadGlobalSetting(Settings::values.enable_accurate_vibrations); |
| 395 | ReadGlobalSetting(Settings::values.motion_enabled); | 394 | ReadGlobalSetting(Settings::values.motion_enabled); |
| 396 | 395 | ||
| 396 | ReadBasicSetting(Settings::values.controller_navigation); | ||
| 397 | |||
| 397 | qt_config->endGroup(); | 398 | qt_config->endGroup(); |
| 398 | } | 399 | } |
| 399 | 400 | ||
| @@ -1002,6 +1003,7 @@ void Config::SaveControlValues() { | |||
| 1002 | WriteBasicSetting(Settings::values.keyboard_enabled); | 1003 | WriteBasicSetting(Settings::values.keyboard_enabled); |
| 1003 | WriteBasicSetting(Settings::values.emulate_analog_keyboard); | 1004 | WriteBasicSetting(Settings::values.emulate_analog_keyboard); |
| 1004 | WriteBasicSetting(Settings::values.mouse_panning_sensitivity); | 1005 | WriteBasicSetting(Settings::values.mouse_panning_sensitivity); |
| 1006 | WriteBasicSetting(Settings::values.controller_navigation); | ||
| 1005 | 1007 | ||
| 1006 | WriteBasicSetting(Settings::values.tas_enable); | 1008 | WriteBasicSetting(Settings::values.tas_enable); |
| 1007 | WriteBasicSetting(Settings::values.tas_loop); | 1009 | WriteBasicSetting(Settings::values.tas_loop); |
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 8f4576def..60b20a62f 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -46,7 +46,7 @@ public: | |||
| 46 | default_mouse_buttons; | 46 | default_mouse_buttons; |
| 47 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys; | 47 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys; |
| 48 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods; | 48 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods; |
| 49 | static const std::array<UISettings::Shortcut, 21> default_hotkeys; | 49 | static const std::array<UISettings::Shortcut, 20> default_hotkeys; |
| 50 | 50 | ||
| 51 | static constexpr UISettings::Theme default_theme{ | 51 | static constexpr UISettings::Theme default_theme{ |
| 52 | #ifdef _WIN32 | 52 | #ifdef _WIN32 |
diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index 9241678e4..74f0e0b79 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui | |||
| @@ -429,7 +429,7 @@ | |||
| 429 | </item> | 429 | </item> |
| 430 | <item> | 430 | <item> |
| 431 | <property name="text"> | 431 | <property name="text"> |
| 432 | <string>AMD FidelityFX™️ Super Resolution [Vulkan Only]</string> | 432 | <string>AMD FidelityFX™️ Super Resolution (Vulkan Only)</string> |
| 433 | </property> | 433 | </property> |
| 434 | </item> | 434 | </item> |
| 435 | </widget> | 435 | </widget> |
diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index 65c8e59ac..20fc2599d 100644 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp | |||
| @@ -131,6 +131,7 @@ void ConfigureInputAdvanced::ApplyConfiguration() { | |||
| 131 | Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); | 131 | Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); |
| 132 | Settings::values.enable_raw_input = ui->enable_raw_input->isChecked(); | 132 | Settings::values.enable_raw_input = ui->enable_raw_input->isChecked(); |
| 133 | Settings::values.enable_udp_controller = ui->enable_udp_controller->isChecked(); | 133 | Settings::values.enable_udp_controller = ui->enable_udp_controller->isChecked(); |
| 134 | Settings::values.controller_navigation = ui->controller_navigation->isChecked(); | ||
| 134 | } | 135 | } |
| 135 | 136 | ||
| 136 | void ConfigureInputAdvanced::LoadConfiguration() { | 137 | void ConfigureInputAdvanced::LoadConfiguration() { |
| @@ -162,6 +163,7 @@ void ConfigureInputAdvanced::LoadConfiguration() { | |||
| 162 | ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled); | 163 | ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled); |
| 163 | ui->enable_raw_input->setChecked(Settings::values.enable_raw_input.GetValue()); | 164 | ui->enable_raw_input->setChecked(Settings::values.enable_raw_input.GetValue()); |
| 164 | ui->enable_udp_controller->setChecked(Settings::values.enable_udp_controller.GetValue()); | 165 | ui->enable_udp_controller->setChecked(Settings::values.enable_udp_controller.GetValue()); |
| 166 | ui->controller_navigation->setChecked(Settings::values.controller_navigation.GetValue()); | ||
| 165 | 167 | ||
| 166 | UpdateUIEnabled(); | 168 | UpdateUIEnabled(); |
| 167 | } | 169 | } |
diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui index df0e4d602..66f2075f2 100644 --- a/src/yuzu/configuration/configure_input_advanced.ui +++ b/src/yuzu/configuration/configure_input_advanced.ui | |||
| @@ -2655,6 +2655,19 @@ | |||
| 2655 | </widget> | 2655 | </widget> |
| 2656 | </item> | 2656 | </item> |
| 2657 | <item row="4" column="0"> | 2657 | <item row="4" column="0"> |
| 2658 | <widget class="QCheckBox" name="controller_navigation"> | ||
| 2659 | <property name="minimumSize"> | ||
| 2660 | <size> | ||
| 2661 | <width>0</width> | ||
| 2662 | <height>23</height> | ||
| 2663 | </size> | ||
| 2664 | </property> | ||
| 2665 | <property name="text"> | ||
| 2666 | <string>Controller navigation</string> | ||
| 2667 | </property> | ||
| 2668 | </widget> | ||
| 2669 | </item> | ||
| 2670 | <item row="5" column="0"> | ||
| 2658 | <widget class="QCheckBox" name="mouse_panning"> | 2671 | <widget class="QCheckBox" name="mouse_panning"> |
| 2659 | <property name="minimumSize"> | 2672 | <property name="minimumSize"> |
| 2660 | <size> | 2673 | <size> |
| @@ -2667,7 +2680,7 @@ | |||
| 2667 | </property> | 2680 | </property> |
| 2668 | </widget> | 2681 | </widget> |
| 2669 | </item> | 2682 | </item> |
| 2670 | <item row="4" column="2"> | 2683 | <item row="5" column="2"> |
| 2671 | <widget class="QSpinBox" name="mouse_panning_sensitivity"> | 2684 | <widget class="QSpinBox" name="mouse_panning_sensitivity"> |
| 2672 | <property name="toolTip"> | 2685 | <property name="toolTip"> |
| 2673 | <string>Mouse sensitivity</string> | 2686 | <string>Mouse sensitivity</string> |
| @@ -2689,14 +2702,14 @@ | |||
| 2689 | </property> | 2702 | </property> |
| 2690 | </widget> | 2703 | </widget> |
| 2691 | </item> | 2704 | </item> |
| 2692 | <item row="5" column="0"> | 2705 | <item row="6" column="0"> |
| 2693 | <widget class="QLabel" name="motion_touch"> | 2706 | <widget class="QLabel" name="motion_touch"> |
| 2694 | <property name="text"> | 2707 | <property name="text"> |
| 2695 | <string>Motion / Touch</string> | 2708 | <string>Motion / Touch</string> |
| 2696 | </property> | 2709 | </property> |
| 2697 | </widget> | 2710 | </widget> |
| 2698 | </item> | 2711 | </item> |
| 2699 | <item row="5" column="2"> | 2712 | <item row="6" column="2"> |
| 2700 | <widget class="QPushButton" name="buttonMotionTouch"> | 2713 | <widget class="QPushButton" name="buttonMotionTouch"> |
| 2701 | <property name="text"> | 2714 | <property name="text"> |
| 2702 | <string>Configure</string> | 2715 | <string>Configure</string> |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index d2132b408..7029287a9 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -147,7 +147,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) { | |||
| 147 | // Retrieve the names from Qt | 147 | // Retrieve the names from Qt |
| 148 | if (param.Get("engine", "") == "keyboard") { | 148 | if (param.Get("engine", "") == "keyboard") { |
| 149 | const QString button_str = GetKeyName(param.Get("code", 0)); | 149 | const QString button_str = GetKeyName(param.Get("code", 0)); |
| 150 | return QObject::tr("%1%2").arg(toggle, button_str); | 150 | return QObject::tr("%1%2%3").arg(toggle, inverted, button_str); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | if (common_button_name == Common::Input::ButtonNames::Invalid) { | 153 | if (common_button_name == Common::Input::ButtonNames::Invalid) { |
| @@ -341,7 +341,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 341 | emulated_controller->SetButtonParam(button_id, {}); | 341 | emulated_controller->SetButtonParam(button_id, {}); |
| 342 | button_map[button_id]->setText(tr("[not set]")); | 342 | button_map[button_id]->setText(tr("[not set]")); |
| 343 | }); | 343 | }); |
| 344 | if (param.Has("button") || param.Has("hat")) { | 344 | if (param.Has("code") || param.Has("button") || param.Has("hat")) { |
| 345 | context_menu.addAction(tr("Toggle button"), [&] { | 345 | context_menu.addAction(tr("Toggle button"), [&] { |
| 346 | const bool toggle_value = !param.Get("toggle", false); | 346 | const bool toggle_value = !param.Get("toggle", false); |
| 347 | param.Set("toggle", toggle_value); | 347 | param.Set("toggle", toggle_value); |
| @@ -349,8 +349,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 349 | emulated_controller->SetButtonParam(button_id, param); | 349 | emulated_controller->SetButtonParam(button_id, param); |
| 350 | }); | 350 | }); |
| 351 | context_menu.addAction(tr("Invert button"), [&] { | 351 | context_menu.addAction(tr("Invert button"), [&] { |
| 352 | const bool toggle_value = !param.Get("inverted", false); | 352 | const bool invert_value = !param.Get("inverted", false); |
| 353 | param.Set("inverted", toggle_value); | 353 | param.Set("inverted", invert_value); |
| 354 | button_map[button_id]->setText(ButtonToText(param)); | 354 | button_map[button_id]->setText(ButtonToText(param)); |
| 355 | emulated_controller->SetButtonParam(button_id, param); | 355 | emulated_controller->SetButtonParam(button_id, param); |
| 356 | }); | 356 | }); |
| @@ -510,28 +510,37 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 510 | 510 | ||
| 511 | analog_map_modifier_button[analog_id]->setContextMenuPolicy(Qt::CustomContextMenu); | 511 | analog_map_modifier_button[analog_id]->setContextMenuPolicy(Qt::CustomContextMenu); |
| 512 | 512 | ||
| 513 | connect(analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested, | 513 | connect( |
| 514 | [=, this](const QPoint& menu_location) { | 514 | analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested, |
| 515 | QMenu context_menu; | 515 | [=, this](const QPoint& menu_location) { |
| 516 | Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); | 516 | QMenu context_menu; |
| 517 | context_menu.addAction(tr("Clear"), [&] { | 517 | Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); |
| 518 | param.Set("modifier", ""); | 518 | context_menu.addAction(tr("Clear"), [&] { |
| 519 | analog_map_modifier_button[analog_id]->setText(tr("[not set]")); | 519 | param.Set("modifier", ""); |
| 520 | emulated_controller->SetStickParam(analog_id, param); | 520 | analog_map_modifier_button[analog_id]->setText(tr("[not set]")); |
| 521 | }); | 521 | emulated_controller->SetStickParam(analog_id, param); |
| 522 | context_menu.addAction(tr("Toggle button"), [&] { | 522 | }); |
| 523 | Common::ParamPackage modifier_param = | 523 | context_menu.addAction(tr("Toggle button"), [&] { |
| 524 | Common::ParamPackage{param.Get("modifier", "")}; | 524 | Common::ParamPackage modifier_param = |
| 525 | const bool toggle_value = !modifier_param.Get("toggle", false); | 525 | Common::ParamPackage{param.Get("modifier", "")}; |
| 526 | modifier_param.Set("toggle", toggle_value); | 526 | const bool toggle_value = !modifier_param.Get("toggle", false); |
| 527 | param.Set("modifier", modifier_param.Serialize()); | 527 | modifier_param.Set("toggle", toggle_value); |
| 528 | analog_map_modifier_button[analog_id]->setText( | 528 | param.Set("modifier", modifier_param.Serialize()); |
| 529 | ButtonToText(modifier_param)); | 529 | analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param)); |
| 530 | emulated_controller->SetStickParam(analog_id, param); | 530 | emulated_controller->SetStickParam(analog_id, param); |
| 531 | }); | ||
| 532 | context_menu.exec( | ||
| 533 | analog_map_modifier_button[analog_id]->mapToGlobal(menu_location)); | ||
| 534 | }); | 531 | }); |
| 532 | context_menu.addAction(tr("Invert button"), [&] { | ||
| 533 | Common::ParamPackage modifier_param = | ||
| 534 | Common::ParamPackage{param.Get("modifier", "")}; | ||
| 535 | const bool invert_value = !modifier_param.Get("inverted", false); | ||
| 536 | modifier_param.Set("inverted", invert_value); | ||
| 537 | param.Set("modifier", modifier_param.Serialize()); | ||
| 538 | analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param)); | ||
| 539 | emulated_controller->SetStickParam(analog_id, param); | ||
| 540 | }); | ||
| 541 | context_menu.exec( | ||
| 542 | analog_map_modifier_button[analog_id]->mapToGlobal(menu_location)); | ||
| 543 | }); | ||
| 535 | 544 | ||
| 536 | connect(analog_map_range_spinbox[analog_id], qOverload<int>(&QSpinBox::valueChanged), | 545 | connect(analog_map_range_spinbox[analog_id], qOverload<int>(&QSpinBox::valueChanged), |
| 537 | [=, this] { | 546 | [=, this] { |
diff --git a/src/yuzu/hotkeys.cpp b/src/yuzu/hotkeys.cpp index d96497c4e..6ed9611c7 100644 --- a/src/yuzu/hotkeys.cpp +++ b/src/yuzu/hotkeys.cpp | |||
| @@ -190,6 +190,9 @@ void ControllerShortcut::ControllerUpdateEvent(Core::HID::ControllerTriggerType | |||
| 190 | if (type != Core::HID::ControllerTriggerType::Button) { | 190 | if (type != Core::HID::ControllerTriggerType::Button) { |
| 191 | return; | 191 | return; |
| 192 | } | 192 | } |
| 193 | if (!Settings::values.controller_navigation) { | ||
| 194 | return; | ||
| 195 | } | ||
| 193 | if (button_sequence.npad.raw == Core::HID::NpadButton::None && | 196 | if (button_sequence.npad.raw == Core::HID::NpadButton::None && |
| 194 | button_sequence.capture.raw == 0 && button_sequence.home.raw == 0) { | 197 | button_sequence.capture.raw == 0 && button_sequence.home.raw == 0) { |
| 195 | return; | 198 | return; |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e10eb70a2..d9e689d14 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1008,33 +1008,24 @@ void GMainWindow::InitializeHotkeys() { | |||
| 1008 | ToggleFullscreen(); | 1008 | ToggleFullscreen(); |
| 1009 | } | 1009 | } |
| 1010 | }); | 1010 | }); |
| 1011 | connect_shortcut(QStringLiteral("Toggle Speed Limit"), [&] { | ||
| 1012 | Settings::values.use_speed_limit.SetValue(!Settings::values.use_speed_limit.GetValue()); | ||
| 1013 | UpdateStatusBar(); | ||
| 1014 | }); | ||
| 1015 | constexpr u16 SPEED_LIMIT_STEP = 5; | ||
| 1016 | connect_shortcut(QStringLiteral("Increase Speed Limit"), [&] { | ||
| 1017 | if (Settings::values.speed_limit.GetValue() < 9999 - SPEED_LIMIT_STEP) { | ||
| 1018 | Settings::values.speed_limit.SetValue(SPEED_LIMIT_STEP + | ||
| 1019 | Settings::values.speed_limit.GetValue()); | ||
| 1020 | UpdateStatusBar(); | ||
| 1021 | } | ||
| 1022 | }); | ||
| 1023 | connect_shortcut(QStringLiteral("Decrease Speed Limit"), [&] { | ||
| 1024 | if (Settings::values.speed_limit.GetValue() > SPEED_LIMIT_STEP) { | ||
| 1025 | Settings::values.speed_limit.SetValue(Settings::values.speed_limit.GetValue() - | ||
| 1026 | SPEED_LIMIT_STEP); | ||
| 1027 | UpdateStatusBar(); | ||
| 1028 | } | ||
| 1029 | }); | ||
| 1030 | connect_shortcut(QStringLiteral("Change Docked Mode"), [&] { | 1011 | connect_shortcut(QStringLiteral("Change Docked Mode"), [&] { |
| 1031 | Settings::values.use_docked_mode.SetValue(!Settings::values.use_docked_mode.GetValue()); | 1012 | Settings::values.use_docked_mode.SetValue(!Settings::values.use_docked_mode.GetValue()); |
| 1032 | OnDockedModeChanged(!Settings::values.use_docked_mode.GetValue(), | 1013 | OnDockedModeChanged(!Settings::values.use_docked_mode.GetValue(), |
| 1033 | Settings::values.use_docked_mode.GetValue(), *system); | 1014 | Settings::values.use_docked_mode.GetValue(), *system); |
| 1034 | dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue()); | 1015 | dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue()); |
| 1035 | }); | 1016 | }); |
| 1036 | connect_shortcut(QStringLiteral("Mute Audio"), | 1017 | connect_shortcut(QStringLiteral("Audio Mute/Unmute"), |
| 1037 | [] { Settings::values.audio_muted = !Settings::values.audio_muted; }); | 1018 | [] { Settings::values.audio_muted = !Settings::values.audio_muted; }); |
| 1019 | connect_shortcut(QStringLiteral("Audio Volume Down"), [] { | ||
| 1020 | const auto current_volume = static_cast<int>(Settings::values.volume.GetValue()); | ||
| 1021 | const auto new_volume = std::max(current_volume - 5, 0); | ||
| 1022 | Settings::values.volume.SetValue(static_cast<u8>(new_volume)); | ||
| 1023 | }); | ||
| 1024 | connect_shortcut(QStringLiteral("Audio Volume Up"), [] { | ||
| 1025 | const auto current_volume = static_cast<int>(Settings::values.volume.GetValue()); | ||
| 1026 | const auto new_volume = std::min(current_volume + 5, 100); | ||
| 1027 | Settings::values.volume.SetValue(static_cast<u8>(new_volume)); | ||
| 1028 | }); | ||
| 1038 | connect_shortcut(QStringLiteral("Toggle Framerate Limit"), [] { | 1029 | connect_shortcut(QStringLiteral("Toggle Framerate Limit"), [] { |
| 1039 | Settings::values.disable_fps_limit.SetValue(!Settings::values.disable_fps_limit.GetValue()); | 1030 | Settings::values.disable_fps_limit.SetValue(!Settings::values.disable_fps_limit.GetValue()); |
| 1040 | }); | 1031 | }); |
diff --git a/src/yuzu/util/controller_navigation.cpp b/src/yuzu/util/controller_navigation.cpp index 86fb28b9f..c2b13123d 100644 --- a/src/yuzu/util/controller_navigation.cpp +++ b/src/yuzu/util/controller_navigation.cpp | |||
| @@ -40,6 +40,9 @@ void ControllerNavigation::TriggerButton(Settings::NativeButton::Values native_b | |||
| 40 | 40 | ||
| 41 | void ControllerNavigation::ControllerUpdateEvent(Core::HID::ControllerTriggerType type) { | 41 | void ControllerNavigation::ControllerUpdateEvent(Core::HID::ControllerTriggerType type) { |
| 42 | std::lock_guard lock{mutex}; | 42 | std::lock_guard lock{mutex}; |
| 43 | if (!Settings::values.controller_navigation) { | ||
| 44 | return; | ||
| 45 | } | ||
| 43 | if (type == Core::HID::ControllerTriggerType::Button) { | 46 | if (type == Core::HID::ControllerTriggerType::Button) { |
| 44 | ControllerUpdateButton(); | 47 | ControllerUpdateButton(); |
| 45 | return; | 48 | return; |