diff options
| author | 2022-12-03 12:09:21 -0500 | |
|---|---|---|
| committer | 2022-12-03 12:09:21 -0500 | |
| commit | 22aff09b33941cdf907e474cb86117fef838abba (patch) | |
| tree | 73a747be44fd2ba994c3d40c8f6ea18633c0f880 | |
| parent | Merge pull request #9353 from vonchenplus/draw_indexed (diff) | |
| parent | general: fix compile for Apple Clang (diff) | |
| download | yuzu-22aff09b33941cdf907e474cb86117fef838abba.tar.gz yuzu-22aff09b33941cdf907e474cb86117fef838abba.tar.xz yuzu-22aff09b33941cdf907e474cb86117fef838abba.zip | |
Merge pull request #9289 from liamwhite/fruit-company
general: fix compile for Apple Clang
79 files changed, 952 insertions, 37 deletions
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 9740e017c..25ef0c058 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt | |||
| @@ -67,6 +67,9 @@ if (YUZU_USE_EXTERNAL_SDL2) | |||
| 67 | endif() | 67 | endif() |
| 68 | set(SDL_STATIC ON) | 68 | set(SDL_STATIC ON) |
| 69 | set(SDL_SHARED OFF) | 69 | set(SDL_SHARED OFF) |
| 70 | if (APPLE) | ||
| 71 | set(SDL_FILE ON) | ||
| 72 | endif() | ||
| 70 | 73 | ||
| 71 | add_subdirectory(SDL EXCLUDE_FROM_ALL) | 74 | add_subdirectory(SDL EXCLUDE_FROM_ALL) |
| 72 | endif() | 75 | endif() |
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0ac3d254e..4bd5aa50b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt | |||
| @@ -112,6 +112,8 @@ else() | |||
| 112 | 112 | ||
| 113 | $<$<CXX_COMPILER_ID:Clang>:-Wno-braced-scalar-init> | 113 | $<$<CXX_COMPILER_ID:Clang>:-Wno-braced-scalar-init> |
| 114 | $<$<CXX_COMPILER_ID:Clang>:-Wno-unused-private-field> | 114 | $<$<CXX_COMPILER_ID:Clang>:-Wno-unused-private-field> |
| 115 | $<$<CXX_COMPILER_ID:AppleClang>:-Wno-braced-scalar-init> | ||
| 116 | $<$<CXX_COMPILER_ID:AppleClang>:-Wno-unused-private-field> | ||
| 115 | ) | 117 | ) |
| 116 | 118 | ||
| 117 | if (ARCHITECTURE_x86_64) | 119 | if (ARCHITECTURE_x86_64) |
diff --git a/src/audio_core/audio_event.cpp b/src/audio_core/audio_event.cpp index 424049c7a..d15568e1f 100644 --- a/src/audio_core/audio_event.cpp +++ b/src/audio_core/audio_event.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include "audio_core/audio_event.h" | 4 | #include "audio_core/audio_event.h" |
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "common/polyfill_ranges.h" | ||
| 6 | 7 | ||
| 7 | namespace AudioCore { | 8 | namespace AudioCore { |
| 8 | 9 | ||
diff --git a/src/audio_core/audio_manager.h b/src/audio_core/audio_manager.h index abf077de4..02270242a 100644 --- a/src/audio_core/audio_manager.h +++ b/src/audio_core/audio_manager.h | |||
| @@ -9,6 +9,8 @@ | |||
| 9 | #include <mutex> | 9 | #include <mutex> |
| 10 | #include <thread> | 10 | #include <thread> |
| 11 | 11 | ||
| 12 | #include "common/polyfill_thread.h" | ||
| 13 | |||
| 12 | #include "audio_core/audio_event.h" | 14 | #include "audio_core/audio_event.h" |
| 13 | 15 | ||
| 14 | union Result; | 16 | union Result; |
diff --git a/src/audio_core/audio_render_manager.h b/src/audio_core/audio_render_manager.h index bf4837190..fffa5944d 100644 --- a/src/audio_core/audio_render_manager.h +++ b/src/audio_core/audio_render_manager.h | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <mutex> | 8 | #include <mutex> |
| 9 | 9 | ||
| 10 | #include "common/polyfill_thread.h" | ||
| 11 | |||
| 10 | #include "audio_core/common/common.h" | 12 | #include "audio_core/common/common.h" |
| 11 | #include "audio_core/renderer/system_manager.h" | 13 | #include "audio_core/renderer/system_manager.h" |
| 12 | #include "core/hle/service/audio/errors.h" | 14 | #include "core/hle/service/audio/errors.h" |
diff --git a/src/audio_core/common/feature_support.h b/src/audio_core/common/feature_support.h index 55c9e690d..e71905ae8 100644 --- a/src/audio_core/common/feature_support.h +++ b/src/audio_core/common/feature_support.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/assert.h" | 10 | #include "common/assert.h" |
| 11 | #include "common/common_funcs.h" | 11 | #include "common/common_funcs.h" |
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "common/polyfill_ranges.h" | ||
| 13 | 14 | ||
| 14 | namespace AudioCore { | 15 | namespace AudioCore { |
| 15 | constexpr u32 CurrentRevision = 11; | 16 | constexpr u32 CurrentRevision = 11; |
diff --git a/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp b/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp index c4bf3943a..2187d8a65 100644 --- a/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp +++ b/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include "audio_core/renderer/adsp/command_list_processor.h" | 6 | #include "audio_core/renderer/adsp/command_list_processor.h" |
| 7 | #include "audio_core/renderer/command/effect/i3dl2_reverb.h" | 7 | #include "audio_core/renderer/command/effect/i3dl2_reverb.h" |
| 8 | #include "common/polyfill_ranges.h" | ||
| 8 | 9 | ||
| 9 | namespace AudioCore::AudioRenderer { | 10 | namespace AudioCore::AudioRenderer { |
| 10 | 11 | ||
diff --git a/src/audio_core/renderer/command/effect/reverb.cpp b/src/audio_core/renderer/command/effect/reverb.cpp index fe2b1eb43..427489214 100644 --- a/src/audio_core/renderer/command/effect/reverb.cpp +++ b/src/audio_core/renderer/command/effect/reverb.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "audio_core/renderer/adsp/command_list_processor.h" | 7 | #include "audio_core/renderer/adsp/command_list_processor.h" |
| 8 | #include "audio_core/renderer/command/effect/reverb.h" | 8 | #include "audio_core/renderer/command/effect/reverb.h" |
| 9 | #include "common/polyfill_ranges.h" | ||
| 9 | 10 | ||
| 10 | namespace AudioCore::AudioRenderer { | 11 | namespace AudioCore::AudioRenderer { |
| 11 | 12 | ||
diff --git a/src/audio_core/renderer/mix/mix_context.cpp b/src/audio_core/renderer/mix/mix_context.cpp index 2427c83ed..35b748ede 100644 --- a/src/audio_core/renderer/mix/mix_context.cpp +++ b/src/audio_core/renderer/mix/mix_context.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include "audio_core/renderer/mix/mix_context.h" | 6 | #include "audio_core/renderer/mix/mix_context.h" |
| 7 | #include "audio_core/renderer/splitter/splitter_context.h" | 7 | #include "audio_core/renderer/splitter/splitter_context.h" |
| 8 | #include "common/polyfill_ranges.h" | ||
| 8 | 9 | ||
| 9 | namespace AudioCore::AudioRenderer { | 10 | namespace AudioCore::AudioRenderer { |
| 10 | 11 | ||
diff --git a/src/audio_core/renderer/voice/voice_context.cpp b/src/audio_core/renderer/voice/voice_context.cpp index a501a677d..16a3e839d 100644 --- a/src/audio_core/renderer/voice/voice_context.cpp +++ b/src/audio_core/renderer/voice/voice_context.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <ranges> | 4 | #include <ranges> |
| 5 | 5 | ||
| 6 | #include "audio_core/renderer/voice/voice_context.h" | 6 | #include "audio_core/renderer/voice/voice_context.h" |
| 7 | #include "common/polyfill_ranges.h" | ||
| 7 | 8 | ||
| 8 | namespace AudioCore::AudioRenderer { | 9 | namespace AudioCore::AudioRenderer { |
| 9 | 10 | ||
diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 67e194e3c..06c2a876e 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp | |||
| @@ -170,8 +170,8 @@ void SinkStream::ProcessAudioIn(std::span<const s16> input_buffer, std::size_t n | |||
| 170 | 170 | ||
| 171 | // Get the minimum frames available between the currently playing buffer, and the | 171 | // Get the minimum frames available between the currently playing buffer, and the |
| 172 | // amount we have left to fill | 172 | // amount we have left to fill |
| 173 | size_t frames_available{std::min(playing_buffer.frames - playing_buffer.frames_played, | 173 | size_t frames_available{std::min<u64>(playing_buffer.frames - playing_buffer.frames_played, |
| 174 | num_frames - frames_written)}; | 174 | num_frames - frames_written)}; |
| 175 | 175 | ||
| 176 | samples_buffer.Push(&input_buffer[frames_written * frame_size], | 176 | samples_buffer.Push(&input_buffer[frames_written * frame_size], |
| 177 | frames_available * frame_size); | 177 | frames_available * frame_size); |
| @@ -241,8 +241,8 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz | |||
| 241 | 241 | ||
| 242 | // Get the minimum frames available between the currently playing buffer, and the | 242 | // Get the minimum frames available between the currently playing buffer, and the |
| 243 | // amount we have left to fill | 243 | // amount we have left to fill |
| 244 | size_t frames_available{std::min(playing_buffer.frames - playing_buffer.frames_played, | 244 | size_t frames_available{std::min<u64>(playing_buffer.frames - playing_buffer.frames_played, |
| 245 | num_frames - frames_written)}; | 245 | num_frames - frames_written)}; |
| 246 | 246 | ||
| 247 | samples_buffer.Pop(&output_buffer[frames_written * frame_size], | 247 | samples_buffer.Pop(&output_buffer[frames_written * frame_size], |
| 248 | frames_available * frame_size); | 248 | frames_available * frame_size); |
diff --git a/src/common/fs/file.cpp b/src/common/fs/file.cpp index fa8422c41..656b03cc5 100644 --- a/src/common/fs/file.cpp +++ b/src/common/fs/file.cpp | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <vector> | ||
| 5 | |||
| 4 | #include "common/fs/file.h" | 6 | #include "common/fs/file.h" |
| 5 | #include "common/fs/fs.h" | 7 | #include "common/fs/fs.h" |
| 6 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
diff --git a/src/common/fs/fs_util.cpp b/src/common/fs/fs_util.cpp index eb4ac1deb..813a713c3 100644 --- a/src/common/fs/fs_util.cpp +++ b/src/common/fs/fs_util.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <algorithm> | 4 | #include <algorithm> |
| 5 | 5 | ||
| 6 | #include "common/fs/fs_util.h" | 6 | #include "common/fs/fs_util.h" |
| 7 | #include "common/polyfill_ranges.h" | ||
| 7 | 8 | ||
| 8 | namespace Common::FS { | 9 | namespace Common::FS { |
| 9 | 10 | ||
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index 1074f2421..defa3e918 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <algorithm> | 4 | #include <algorithm> |
| 5 | #include <sstream> | ||
| 5 | #include <unordered_map> | 6 | #include <unordered_map> |
| 6 | 7 | ||
| 7 | #include "common/fs/fs.h" | 8 | #include "common/fs/fs.h" |
diff --git a/src/common/input.h b/src/common/input.h index 449e0193f..fc14fd7bf 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <string> | 8 | #include <string> |
| 9 | #include <unordered_map> | 9 | #include <unordered_map> |
| 10 | #include <utility> | 10 | #include <utility> |
| 11 | #include <vector> | ||
| 11 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 12 | #include "common/param_package.h" | 13 | #include "common/param_package.h" |
| 13 | #include "common/uuid.h" | 14 | #include "common/uuid.h" |
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 15d92505e..2a3bded40 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | #include <atomic> | 4 | #include <atomic> |
| 5 | #include <chrono> | 5 | #include <chrono> |
| 6 | #include <climits> | 6 | #include <climits> |
| 7 | #include <stop_token> | ||
| 8 | #include <thread> | 7 | #include <thread> |
| 9 | 8 | ||
| 10 | #include <fmt/format.h> | 9 | #include <fmt/format.h> |
| @@ -18,6 +17,7 @@ | |||
| 18 | #include "common/fs/fs_paths.h" | 17 | #include "common/fs/fs_paths.h" |
| 19 | #include "common/fs/path_util.h" | 18 | #include "common/fs/path_util.h" |
| 20 | #include "common/literals.h" | 19 | #include "common/literals.h" |
| 20 | #include "common/polyfill_thread.h" | ||
| 21 | #include "common/thread.h" | 21 | #include "common/thread.h" |
| 22 | 22 | ||
| 23 | #include "common/logging/backend.h" | 23 | #include "common/logging/backend.h" |
diff --git a/src/common/polyfill_ranges.h b/src/common/polyfill_ranges.h new file mode 100644 index 000000000..ca44bfaef --- /dev/null +++ b/src/common/polyfill_ranges.h | |||
| @@ -0,0 +1,530 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2022 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | // | ||
| 5 | // TODO: remove this file when ranges are supported by all compilation targets | ||
| 6 | // | ||
| 7 | |||
| 8 | #pragma once | ||
| 9 | |||
| 10 | #include <algorithm> | ||
| 11 | #include <utility> | ||
| 12 | #include <version> | ||
| 13 | |||
| 14 | #ifndef __cpp_lib_ranges | ||
| 15 | |||
| 16 | namespace std { | ||
| 17 | namespace ranges { | ||
| 18 | |||
| 19 | template <typename T> | ||
| 20 | concept range = requires(T& t) { | ||
| 21 | begin(t); | ||
| 22 | end(t); | ||
| 23 | }; | ||
| 24 | |||
| 25 | template <typename T> | ||
| 26 | concept input_range = range<T>; | ||
| 27 | |||
| 28 | template <typename T> | ||
| 29 | concept output_range = range<T>; | ||
| 30 | |||
| 31 | template <range R> | ||
| 32 | using range_difference_t = ptrdiff_t; | ||
| 33 | |||
| 34 | // | ||
| 35 | // find, find_if, find_if_not | ||
| 36 | // | ||
| 37 | |||
| 38 | struct find_fn { | ||
| 39 | template <typename Iterator, typename T, typename Proj = std::identity> | ||
| 40 | constexpr Iterator operator()(Iterator first, Iterator last, const T& value, | ||
| 41 | Proj proj = {}) const { | ||
| 42 | for (; first != last; ++first) { | ||
| 43 | if (std::invoke(proj, *first) == value) { | ||
| 44 | return first; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | return first; | ||
| 48 | } | ||
| 49 | |||
| 50 | template <ranges::input_range R, typename T, typename Proj = std::identity> | ||
| 51 | constexpr ranges::iterator_t<R> operator()(R&& r, const T& value, Proj proj = {}) const { | ||
| 52 | return operator()(ranges::begin(r), ranges::end(r), value, std::ref(proj)); | ||
| 53 | } | ||
| 54 | }; | ||
| 55 | |||
| 56 | struct find_if_fn { | ||
| 57 | template <typename Iterator, typename Proj = std::identity, typename Pred> | ||
| 58 | constexpr Iterator operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const { | ||
| 59 | for (; first != last; ++first) { | ||
| 60 | if (std::invoke(pred, std::invoke(proj, *first))) { | ||
| 61 | return first; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | return first; | ||
| 65 | } | ||
| 66 | |||
| 67 | template <ranges::input_range R, typename Proj = std::identity, typename Pred> | ||
| 68 | constexpr ranges::iterator_t<R> operator()(R&& r, Pred pred, Proj proj = {}) const { | ||
| 69 | return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj)); | ||
| 70 | } | ||
| 71 | }; | ||
| 72 | |||
| 73 | struct find_if_not_fn { | ||
| 74 | template <typename Iterator, typename Proj = std::identity, typename Pred> | ||
| 75 | constexpr Iterator operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const { | ||
| 76 | for (; first != last; ++first) { | ||
| 77 | if (!std::invoke(pred, std::invoke(proj, *first))) { | ||
| 78 | return first; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | return first; | ||
| 82 | } | ||
| 83 | |||
| 84 | template <ranges::input_range R, typename Proj = std::identity, typename Pred> | ||
| 85 | constexpr ranges::iterator_t<R> operator()(R&& r, Pred pred, Proj proj = {}) const { | ||
| 86 | return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj)); | ||
| 87 | } | ||
| 88 | }; | ||
| 89 | |||
| 90 | inline constexpr find_fn find; | ||
| 91 | inline constexpr find_if_fn find_if; | ||
| 92 | inline constexpr find_if_not_fn find_if_not; | ||
| 93 | |||
| 94 | // | ||
| 95 | // any_of, all_of, none_of | ||
| 96 | // | ||
| 97 | |||
| 98 | struct all_of_fn { | ||
| 99 | template <typename Iterator, typename Proj = std::identity, typename Pred> | ||
| 100 | constexpr bool operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const { | ||
| 101 | return ranges::find_if_not(first, last, std::ref(pred), std::ref(proj)) == last; | ||
| 102 | } | ||
| 103 | |||
| 104 | template <ranges::input_range R, typename Proj = std::identity, typename Pred> | ||
| 105 | constexpr bool operator()(R&& r, Pred pred, Proj proj = {}) const { | ||
| 106 | return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj)); | ||
| 107 | } | ||
| 108 | }; | ||
| 109 | |||
| 110 | struct any_of_fn { | ||
| 111 | template <typename Iterator, typename Proj = std::identity, typename Pred> | ||
| 112 | constexpr bool operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const { | ||
| 113 | return ranges::find_if(first, last, std::ref(pred), std::ref(proj)) != last; | ||
| 114 | } | ||
| 115 | |||
| 116 | template <ranges::input_range R, typename Proj = std::identity, typename Pred> | ||
| 117 | constexpr bool operator()(R&& r, Pred pred, Proj proj = {}) const { | ||
| 118 | return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj)); | ||
| 119 | } | ||
| 120 | }; | ||
| 121 | |||
| 122 | struct none_of_fn { | ||
| 123 | template <typename Iterator, typename Proj = std::identity, typename Pred> | ||
| 124 | constexpr bool operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const { | ||
| 125 | return ranges::find_if(first, last, std::ref(pred), std::ref(proj)) == last; | ||
| 126 | } | ||
| 127 | |||
| 128 | template <ranges::input_range R, typename Proj = std::identity, typename Pred> | ||
| 129 | constexpr bool operator()(R&& r, Pred pred, Proj proj = {}) const { | ||
| 130 | return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj)); | ||
| 131 | } | ||
| 132 | }; | ||
| 133 | |||
| 134 | inline constexpr any_of_fn any_of; | ||
| 135 | inline constexpr all_of_fn all_of; | ||
| 136 | inline constexpr none_of_fn none_of; | ||
| 137 | |||
| 138 | // | ||
| 139 | // count, count_if | ||
| 140 | // | ||
| 141 | |||
| 142 | struct count_fn { | ||
| 143 | template <typename Iterator, typename T, typename Proj = std::identity> | ||
| 144 | constexpr ptrdiff_t operator()(Iterator first, Iterator last, const T& value, | ||
| 145 | Proj proj = {}) const { | ||
| 146 | ptrdiff_t counter = 0; | ||
| 147 | for (; first != last; ++first) | ||
| 148 | if (std::invoke(proj, *first) == value) | ||
| 149 | ++counter; | ||
| 150 | return counter; | ||
| 151 | } | ||
| 152 | |||
| 153 | template <ranges::input_range R, typename T, typename Proj = std::identity> | ||
| 154 | constexpr ptrdiff_t operator()(R&& r, const T& value, Proj proj = {}) const { | ||
| 155 | return operator()(ranges::begin(r), ranges::end(r), value, std::ref(proj)); | ||
| 156 | } | ||
| 157 | }; | ||
| 158 | |||
| 159 | struct count_if_fn { | ||
| 160 | template <typename Iterator, typename Proj = std::identity, typename Pred> | ||
| 161 | constexpr ptrdiff_t operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const { | ||
| 162 | ptrdiff_t counter = 0; | ||
| 163 | for (; first != last; ++first) | ||
| 164 | if (std::invoke(pred, std::invoke(proj, *first))) | ||
| 165 | ++counter; | ||
| 166 | return counter; | ||
| 167 | } | ||
| 168 | |||
| 169 | template <ranges::input_range R, typename Proj = std::identity, typename Pred> | ||
| 170 | constexpr ptrdiff_t operator()(R&& r, Pred pred, Proj proj = {}) const { | ||
| 171 | return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj)); | ||
| 172 | } | ||
| 173 | }; | ||
| 174 | |||
| 175 | inline constexpr count_fn count; | ||
| 176 | inline constexpr count_if_fn count_if; | ||
| 177 | |||
| 178 | // | ||
| 179 | // transform | ||
| 180 | // | ||
| 181 | |||
| 182 | struct transform_fn { | ||
| 183 | template <typename InputIterator, typename OutputIterator, typename F, | ||
| 184 | typename Proj = std::identity> | ||
| 185 | constexpr void operator()(InputIterator first1, InputIterator last1, OutputIterator result, | ||
| 186 | F op, Proj proj = {}) const { | ||
| 187 | for (; first1 != last1; ++first1, (void)++result) { | ||
| 188 | *result = std::invoke(op, std::invoke(proj, *first1)); | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | template <ranges::input_range R, typename OutputIterator, typename F, | ||
| 193 | typename Proj = std::identity> | ||
| 194 | constexpr void operator()(R&& r, OutputIterator result, F op, Proj proj = {}) const { | ||
| 195 | return operator()(ranges::begin(r), ranges::end(r), result, std::ref(op), std::ref(proj)); | ||
| 196 | } | ||
| 197 | }; | ||
| 198 | |||
| 199 | inline constexpr transform_fn transform; | ||
| 200 | |||
| 201 | // | ||
| 202 | // sort | ||
| 203 | // | ||
| 204 | |||
| 205 | struct sort_fn { | ||
| 206 | template <typename Iterator, typename Comp = ranges::less, typename Proj = std::identity> | ||
| 207 | constexpr void operator()(Iterator first, Iterator last, Comp comp = {}, Proj proj = {}) const { | ||
| 208 | if (first == last) | ||
| 209 | return; | ||
| 210 | |||
| 211 | Iterator last_iter = ranges::next(first, last); | ||
| 212 | std::sort(first, last_iter, | ||
| 213 | [&](auto& lhs, auto& rhs) { return comp(proj(lhs), proj(rhs)); }); | ||
| 214 | } | ||
| 215 | |||
| 216 | template <ranges::input_range R, typename Comp = ranges::less, typename Proj = std::identity> | ||
| 217 | constexpr void operator()(R&& r, Comp comp = {}, Proj proj = {}) const { | ||
| 218 | return operator()(ranges::begin(r), ranges::end(r), std::move(comp), std::move(proj)); | ||
| 219 | } | ||
| 220 | }; | ||
| 221 | |||
| 222 | inline constexpr sort_fn sort; | ||
| 223 | |||
| 224 | // | ||
| 225 | // fill | ||
| 226 | // | ||
| 227 | |||
| 228 | struct fill_fn { | ||
| 229 | template <typename T, typename OutputIterator> | ||
| 230 | constexpr OutputIterator operator()(OutputIterator first, OutputIterator last, | ||
| 231 | const T& value) const { | ||
| 232 | while (first != last) { | ||
| 233 | *first++ = value; | ||
| 234 | } | ||
| 235 | |||
| 236 | return first; | ||
| 237 | } | ||
| 238 | |||
| 239 | template <typename T, ranges::output_range R> | ||
| 240 | constexpr ranges::iterator_t<R> operator()(R&& r, const T& value) const { | ||
| 241 | return operator()(ranges::begin(r), ranges::end(r), value); | ||
| 242 | } | ||
| 243 | }; | ||
| 244 | |||
| 245 | inline constexpr fill_fn fill; | ||
| 246 | |||
| 247 | // | ||
| 248 | // for_each | ||
| 249 | // | ||
| 250 | |||
| 251 | struct for_each_fn { | ||
| 252 | template <typename Iterator, typename Proj = std::identity, typename Fun> | ||
| 253 | constexpr void operator()(Iterator first, Iterator last, Fun f, Proj proj = {}) const { | ||
| 254 | for (; first != last; ++first) { | ||
| 255 | std::invoke(f, std::invoke(proj, *first)); | ||
| 256 | } | ||
| 257 | } | ||
| 258 | |||
| 259 | template <ranges::input_range R, typename Proj = std::identity, typename Fun> | ||
| 260 | constexpr void operator()(R&& r, Fun f, Proj proj = {}) const { | ||
| 261 | return operator()(ranges::begin(r), ranges::end(r), std::move(f), std::ref(proj)); | ||
| 262 | } | ||
| 263 | }; | ||
| 264 | |||
| 265 | inline constexpr for_each_fn for_each; | ||
| 266 | |||
| 267 | // | ||
| 268 | // min_element, max_element | ||
| 269 | // | ||
| 270 | |||
| 271 | struct min_element_fn { | ||
| 272 | template <typename Iterator, typename Proj = std::identity, typename Comp = ranges::less> | ||
| 273 | constexpr Iterator operator()(Iterator first, Iterator last, Comp comp = {}, | ||
| 274 | Proj proj = {}) const { | ||
| 275 | if (first == last) { | ||
| 276 | return last; | ||
| 277 | } | ||
| 278 | |||
| 279 | auto smallest = first; | ||
| 280 | ++first; | ||
| 281 | for (; first != last; ++first) { | ||
| 282 | if (!std::invoke(comp, std::invoke(proj, *smallest), std::invoke(proj, *first))) { | ||
| 283 | smallest = first; | ||
| 284 | } | ||
| 285 | } | ||
| 286 | return smallest; | ||
| 287 | } | ||
| 288 | |||
| 289 | template <ranges::input_range R, typename Proj = std::identity, typename Comp = ranges::less> | ||
| 290 | constexpr ranges::iterator_t<R> operator()(R&& r, Comp comp = {}, Proj proj = {}) const { | ||
| 291 | return operator()(ranges::begin(r), ranges::end(r), std::ref(comp), std::ref(proj)); | ||
| 292 | } | ||
| 293 | }; | ||
| 294 | |||
| 295 | struct max_element_fn { | ||
| 296 | template <typename Iterator, typename Proj = std::identity, typename Comp = ranges::less> | ||
| 297 | constexpr Iterator operator()(Iterator first, Iterator last, Comp comp = {}, | ||
| 298 | Proj proj = {}) const { | ||
| 299 | if (first == last) { | ||
| 300 | return last; | ||
| 301 | } | ||
| 302 | |||
| 303 | auto largest = first; | ||
| 304 | ++first; | ||
| 305 | for (; first != last; ++first) { | ||
| 306 | if (std::invoke(comp, std::invoke(proj, *largest), std::invoke(proj, *first))) { | ||
| 307 | largest = first; | ||
| 308 | } | ||
| 309 | } | ||
| 310 | return largest; | ||
| 311 | } | ||
| 312 | |||
| 313 | template <ranges::input_range R, typename Proj = std::identity, typename Comp = ranges::less> | ||
| 314 | constexpr ranges::iterator_t<R> operator()(R&& r, Comp comp = {}, Proj proj = {}) const { | ||
| 315 | return operator()(ranges::begin(r), ranges::end(r), std::ref(comp), std::ref(proj)); | ||
| 316 | } | ||
| 317 | }; | ||
| 318 | |||
| 319 | inline constexpr min_element_fn min_element; | ||
| 320 | inline constexpr max_element_fn max_element; | ||
| 321 | |||
| 322 | // | ||
| 323 | // replace, replace_if | ||
| 324 | // | ||
| 325 | |||
| 326 | struct replace_fn { | ||
| 327 | template <typename Iterator, typename T1, typename T2, typename Proj = std::identity> | ||
| 328 | constexpr Iterator operator()(Iterator first, Iterator last, const T1& old_value, | ||
| 329 | const T2& new_value, Proj proj = {}) const { | ||
| 330 | for (; first != last; ++first) { | ||
| 331 | if (old_value == std::invoke(proj, *first)) { | ||
| 332 | *first = new_value; | ||
| 333 | } | ||
| 334 | } | ||
| 335 | return first; | ||
| 336 | } | ||
| 337 | |||
| 338 | template <ranges::input_range R, typename T1, typename T2, typename Proj = std::identity> | ||
| 339 | constexpr ranges::iterator_t<R> operator()(R&& r, const T1& old_value, const T2& new_value, | ||
| 340 | Proj proj = {}) const { | ||
| 341 | return operator()(ranges::begin(r), ranges::end(r), old_value, new_value, std::move(proj)); | ||
| 342 | } | ||
| 343 | }; | ||
| 344 | |||
| 345 | struct replace_if_fn { | ||
| 346 | template <typename Iterator, typename T, typename Proj = std::identity, typename Pred> | ||
| 347 | constexpr Iterator operator()(Iterator first, Iterator last, Pred pred, const T& new_value, | ||
| 348 | Proj proj = {}) const { | ||
| 349 | for (; first != last; ++first) { | ||
| 350 | if (!!std::invoke(pred, std::invoke(proj, *first))) { | ||
| 351 | *first = new_value; | ||
| 352 | } | ||
| 353 | } | ||
| 354 | return std::move(first); | ||
| 355 | } | ||
| 356 | |||
| 357 | template <ranges::input_range R, typename T, typename Proj = std::identity, typename Pred> | ||
| 358 | constexpr ranges::iterator_t<R> operator()(R&& r, Pred pred, const T& new_value, | ||
| 359 | Proj proj = {}) const { | ||
| 360 | return operator()(ranges::begin(r), ranges::end(r), std::move(pred), new_value, | ||
| 361 | std::move(proj)); | ||
| 362 | } | ||
| 363 | }; | ||
| 364 | |||
| 365 | inline constexpr replace_fn replace; | ||
| 366 | inline constexpr replace_if_fn replace_if; | ||
| 367 | |||
| 368 | // | ||
| 369 | // copy, copy_if | ||
| 370 | // | ||
| 371 | |||
| 372 | struct copy_fn { | ||
| 373 | template <typename InputIterator, typename OutputIterator> | ||
| 374 | constexpr void operator()(InputIterator first, InputIterator last, | ||
| 375 | OutputIterator result) const { | ||
| 376 | for (; first != last; ++first, (void)++result) { | ||
| 377 | *result = *first; | ||
| 378 | } | ||
| 379 | } | ||
| 380 | |||
| 381 | template <ranges::input_range R, typename OutputIterator> | ||
| 382 | constexpr void operator()(R&& r, OutputIterator result) const { | ||
| 383 | return operator()(ranges::begin(r), ranges::end(r), std::move(result)); | ||
| 384 | } | ||
| 385 | }; | ||
| 386 | |||
| 387 | struct copy_if_fn { | ||
| 388 | template <typename InputIterator, typename OutputIterator, typename Proj = std::identity, | ||
| 389 | typename Pred> | ||
| 390 | constexpr void operator()(InputIterator first, InputIterator last, OutputIterator result, | ||
| 391 | Pred pred, Proj proj = {}) const { | ||
| 392 | for (; first != last; ++first) { | ||
| 393 | if (std::invoke(pred, std::invoke(proj, *first))) { | ||
| 394 | *result = *first; | ||
| 395 | ++result; | ||
| 396 | } | ||
| 397 | } | ||
| 398 | } | ||
| 399 | |||
| 400 | template <ranges::input_range R, typename OutputIterator, typename Proj = std::identity, | ||
| 401 | typename Pred> | ||
| 402 | constexpr void operator()(R&& r, OutputIterator result, Pred pred, Proj proj = {}) const { | ||
| 403 | return operator()(ranges::begin(r), ranges::end(r), std::move(result), std::ref(pred), | ||
| 404 | std::ref(proj)); | ||
| 405 | } | ||
| 406 | }; | ||
| 407 | |||
| 408 | inline constexpr copy_fn copy; | ||
| 409 | inline constexpr copy_if_fn copy_if; | ||
| 410 | |||
| 411 | // | ||
| 412 | // generate | ||
| 413 | // | ||
| 414 | |||
| 415 | struct generate_fn { | ||
| 416 | template <typename Iterator, typename F> | ||
| 417 | constexpr Iterator operator()(Iterator first, Iterator last, F gen) const { | ||
| 418 | for (; first != last; *first = std::invoke(gen), ++first) | ||
| 419 | ; | ||
| 420 | return first; | ||
| 421 | } | ||
| 422 | |||
| 423 | template <typename R, std::copy_constructible F> | ||
| 424 | requires std::invocable<F&> && ranges::output_range<R> | ||
| 425 | constexpr ranges::iterator_t<R> operator()(R&& r, F gen) const { | ||
| 426 | return operator()(ranges::begin(r), ranges::end(r), std::move(gen)); | ||
| 427 | } | ||
| 428 | }; | ||
| 429 | |||
| 430 | inline constexpr generate_fn generate; | ||
| 431 | |||
| 432 | // | ||
| 433 | // lower_bound, upper_bound | ||
| 434 | // | ||
| 435 | |||
| 436 | struct lower_bound_fn { | ||
| 437 | template <typename Iterator, typename T, typename Proj = std::identity, | ||
| 438 | typename Comp = ranges::less> | ||
| 439 | constexpr Iterator operator()(Iterator first, Iterator last, const T& value, Comp comp = {}, | ||
| 440 | Proj proj = {}) const { | ||
| 441 | Iterator it; | ||
| 442 | std::ptrdiff_t _count, _step; | ||
| 443 | _count = std::distance(first, last); | ||
| 444 | |||
| 445 | while (_count > 0) { | ||
| 446 | it = first; | ||
| 447 | _step = _count / 2; | ||
| 448 | ranges::advance(it, _step, last); | ||
| 449 | if (comp(std::invoke(proj, *it), value)) { | ||
| 450 | first = ++it; | ||
| 451 | _count -= _step + 1; | ||
| 452 | } else { | ||
| 453 | _count = _step; | ||
| 454 | } | ||
| 455 | } | ||
| 456 | return first; | ||
| 457 | } | ||
| 458 | |||
| 459 | template <ranges::input_range R, typename T, typename Proj = std::identity, | ||
| 460 | typename Comp = ranges::less> | ||
| 461 | constexpr ranges::iterator_t<R> operator()(R&& r, const T& value, Comp comp = {}, | ||
| 462 | Proj proj = {}) const { | ||
| 463 | return operator()(ranges::begin(r), ranges::end(r), value, std::ref(comp), std::ref(proj)); | ||
| 464 | } | ||
| 465 | }; | ||
| 466 | |||
| 467 | struct upper_bound_fn { | ||
| 468 | template <typename Iterator, typename T, typename Proj = std::identity, | ||
| 469 | typename Comp = ranges::less> | ||
| 470 | constexpr Iterator operator()(Iterator first, Iterator last, const T& value, Comp comp = {}, | ||
| 471 | Proj proj = {}) const { | ||
| 472 | Iterator it; | ||
| 473 | std::ptrdiff_t _count, _step; | ||
| 474 | _count = std::distance(first, last); | ||
| 475 | |||
| 476 | while (_count > 0) { | ||
| 477 | it = first; | ||
| 478 | _step = _count / 2; | ||
| 479 | ranges::advance(it, _step, last); | ||
| 480 | if (!comp(value, std::invoke(proj, *it))) { | ||
| 481 | first = ++it; | ||
| 482 | _count -= _step + 1; | ||
| 483 | } else { | ||
| 484 | _count = _step; | ||
| 485 | } | ||
| 486 | } | ||
| 487 | return first; | ||
| 488 | } | ||
| 489 | |||
| 490 | template <ranges::input_range R, typename T, typename Proj = std::identity, | ||
| 491 | typename Comp = ranges::less> | ||
| 492 | constexpr ranges::iterator_t<R> operator()(R&& r, const T& value, Comp comp = {}, | ||
| 493 | Proj proj = {}) const { | ||
| 494 | return operator()(ranges::begin(r), ranges::end(r), value, std::ref(comp), std::ref(proj)); | ||
| 495 | } | ||
| 496 | }; | ||
| 497 | |||
| 498 | inline constexpr lower_bound_fn lower_bound; | ||
| 499 | inline constexpr upper_bound_fn upper_bound; | ||
| 500 | |||
| 501 | // | ||
| 502 | // adjacent_find | ||
| 503 | // | ||
| 504 | |||
| 505 | struct adjacent_find_fn { | ||
| 506 | template <typename Iterator, typename Proj = std::identity, typename Pred = ranges::equal_to> | ||
| 507 | constexpr Iterator operator()(Iterator first, Iterator last, Pred pred = {}, | ||
| 508 | Proj proj = {}) const { | ||
| 509 | if (first == last) | ||
| 510 | return first; | ||
| 511 | auto _next = ranges::next(first); | ||
| 512 | for (; _next != last; ++_next, ++first) | ||
| 513 | if (std::invoke(pred, std::invoke(proj, *first), std::invoke(proj, *_next))) | ||
| 514 | return first; | ||
| 515 | return _next; | ||
| 516 | } | ||
| 517 | |||
| 518 | template <ranges::input_range R, typename Proj = std::identity, | ||
| 519 | typename Pred = ranges::equal_to> | ||
| 520 | constexpr ranges::iterator_t<R> operator()(R&& r, Pred pred = {}, Proj proj = {}) const { | ||
| 521 | return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj)); | ||
| 522 | } | ||
| 523 | }; | ||
| 524 | |||
| 525 | inline constexpr adjacent_find_fn adjacent_find; | ||
| 526 | |||
| 527 | } // namespace ranges | ||
| 528 | } // namespace std | ||
| 529 | |||
| 530 | #endif | ||
diff --git a/src/common/polyfill_thread.h b/src/common/polyfill_thread.h new file mode 100644 index 000000000..5a8d1ce08 --- /dev/null +++ b/src/common/polyfill_thread.h | |||
| @@ -0,0 +1,323 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2022 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | // | ||
| 5 | // TODO: remove this file when jthread is supported by all compilation targets | ||
| 6 | // | ||
| 7 | |||
| 8 | #pragma once | ||
| 9 | |||
| 10 | #include <version> | ||
| 11 | |||
| 12 | #ifdef __cpp_lib_jthread | ||
| 13 | |||
| 14 | #include <stop_token> | ||
| 15 | #include <thread> | ||
| 16 | |||
| 17 | namespace Common { | ||
| 18 | |||
| 19 | template <typename Condvar, typename Lock, typename Pred> | ||
| 20 | void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred&& pred) { | ||
| 21 | cv.wait(lock, token, std::move(pred)); | ||
| 22 | } | ||
| 23 | |||
| 24 | } // namespace Common | ||
| 25 | |||
| 26 | #else | ||
| 27 | |||
| 28 | #include <atomic> | ||
| 29 | #include <functional> | ||
| 30 | #include <list> | ||
| 31 | #include <memory> | ||
| 32 | #include <mutex> | ||
| 33 | #include <optional> | ||
| 34 | #include <thread> | ||
| 35 | #include <type_traits> | ||
| 36 | |||
| 37 | namespace std { | ||
| 38 | namespace polyfill { | ||
| 39 | |||
| 40 | using stop_state_callbacks = list<function<void()>>; | ||
| 41 | |||
| 42 | class stop_state { | ||
| 43 | public: | ||
| 44 | stop_state() = default; | ||
| 45 | ~stop_state() = default; | ||
| 46 | |||
| 47 | bool request_stop() { | ||
| 48 | stop_state_callbacks callbacks; | ||
| 49 | |||
| 50 | { | ||
| 51 | scoped_lock lk{m_lock}; | ||
| 52 | |||
| 53 | if (m_stop_requested.load()) { | ||
| 54 | // Already set, nothing to do | ||
| 55 | return false; | ||
| 56 | } | ||
| 57 | |||
| 58 | // Set as requested | ||
| 59 | m_stop_requested = true; | ||
| 60 | |||
| 61 | // Copy callback list | ||
| 62 | callbacks = m_callbacks; | ||
| 63 | } | ||
| 64 | |||
| 65 | for (auto callback : callbacks) { | ||
| 66 | callback(); | ||
| 67 | } | ||
| 68 | |||
| 69 | return true; | ||
| 70 | } | ||
| 71 | |||
| 72 | bool stop_requested() const { | ||
| 73 | return m_stop_requested.load(); | ||
| 74 | } | ||
| 75 | |||
| 76 | stop_state_callbacks::const_iterator insert_callback(function<void()> f) { | ||
| 77 | stop_state_callbacks::const_iterator ret{}; | ||
| 78 | bool should_run{}; | ||
| 79 | |||
| 80 | { | ||
| 81 | scoped_lock lk{m_lock}; | ||
| 82 | should_run = m_stop_requested.load(); | ||
| 83 | m_callbacks.push_front(f); | ||
| 84 | ret = m_callbacks.begin(); | ||
| 85 | } | ||
| 86 | |||
| 87 | if (should_run) { | ||
| 88 | f(); | ||
| 89 | } | ||
| 90 | |||
| 91 | return ret; | ||
| 92 | } | ||
| 93 | |||
| 94 | void remove_callback(stop_state_callbacks::const_iterator it) { | ||
| 95 | scoped_lock lk{m_lock}; | ||
| 96 | m_callbacks.erase(it); | ||
| 97 | } | ||
| 98 | |||
| 99 | private: | ||
| 100 | mutex m_lock; | ||
| 101 | atomic<bool> m_stop_requested; | ||
| 102 | stop_state_callbacks m_callbacks; | ||
| 103 | }; | ||
| 104 | |||
| 105 | } // namespace polyfill | ||
| 106 | |||
| 107 | class stop_token; | ||
| 108 | class stop_source; | ||
| 109 | struct nostopstate_t { | ||
| 110 | explicit nostopstate_t() = default; | ||
| 111 | }; | ||
| 112 | inline constexpr nostopstate_t nostopstate{}; | ||
| 113 | |||
| 114 | template <class Callback> | ||
| 115 | class stop_callback; | ||
| 116 | |||
| 117 | class stop_token { | ||
| 118 | public: | ||
| 119 | stop_token() noexcept = default; | ||
| 120 | |||
| 121 | stop_token(const stop_token&) noexcept = default; | ||
| 122 | stop_token(stop_token&&) noexcept = default; | ||
| 123 | stop_token& operator=(const stop_token&) noexcept = default; | ||
| 124 | stop_token& operator=(stop_token&&) noexcept = default; | ||
| 125 | ~stop_token() = default; | ||
| 126 | |||
| 127 | void swap(stop_token& other) noexcept { | ||
| 128 | m_stop_state.swap(other.m_stop_state); | ||
| 129 | } | ||
| 130 | |||
| 131 | [[nodiscard]] bool stop_requested() const noexcept { | ||
| 132 | return m_stop_state && m_stop_state->stop_requested(); | ||
| 133 | } | ||
| 134 | [[nodiscard]] bool stop_possible() const noexcept { | ||
| 135 | return m_stop_state != nullptr; | ||
| 136 | } | ||
| 137 | |||
| 138 | private: | ||
| 139 | friend class stop_source; | ||
| 140 | template <typename Callback> | ||
| 141 | friend class stop_callback; | ||
| 142 | stop_token(shared_ptr<polyfill::stop_state> stop_state) : m_stop_state(move(stop_state)) {} | ||
| 143 | |||
| 144 | private: | ||
| 145 | shared_ptr<polyfill::stop_state> m_stop_state; | ||
| 146 | }; | ||
| 147 | |||
| 148 | class stop_source { | ||
| 149 | public: | ||
| 150 | stop_source() : m_stop_state(make_shared<polyfill::stop_state>()) {} | ||
| 151 | explicit stop_source(nostopstate_t) noexcept {} | ||
| 152 | |||
| 153 | stop_source(const stop_source&) noexcept = default; | ||
| 154 | stop_source(stop_source&&) noexcept = default; | ||
| 155 | stop_source& operator=(const stop_source&) noexcept = default; | ||
| 156 | stop_source& operator=(stop_source&&) noexcept = default; | ||
| 157 | ~stop_source() = default; | ||
| 158 | void swap(stop_source& other) noexcept { | ||
| 159 | m_stop_state.swap(other.m_stop_state); | ||
| 160 | } | ||
| 161 | |||
| 162 | [[nodiscard]] stop_token get_token() const noexcept { | ||
| 163 | return stop_token(m_stop_state); | ||
| 164 | } | ||
| 165 | [[nodiscard]] bool stop_possible() const noexcept { | ||
| 166 | return m_stop_state != nullptr; | ||
| 167 | } | ||
| 168 | [[nodiscard]] bool stop_requested() const noexcept { | ||
| 169 | return m_stop_state && m_stop_state->stop_requested(); | ||
| 170 | } | ||
| 171 | bool request_stop() noexcept { | ||
| 172 | return m_stop_state && m_stop_state->request_stop(); | ||
| 173 | } | ||
| 174 | |||
| 175 | private: | ||
| 176 | friend class jthread; | ||
| 177 | explicit stop_source(shared_ptr<polyfill::stop_state> stop_state) | ||
| 178 | : m_stop_state(move(stop_state)) {} | ||
| 179 | |||
| 180 | private: | ||
| 181 | shared_ptr<polyfill::stop_state> m_stop_state; | ||
| 182 | }; | ||
| 183 | |||
| 184 | template <typename Callback> | ||
| 185 | class stop_callback { | ||
| 186 | static_assert(is_nothrow_destructible_v<Callback>); | ||
| 187 | static_assert(is_invocable_v<Callback>); | ||
| 188 | |||
| 189 | public: | ||
| 190 | using callback_type = Callback; | ||
| 191 | |||
| 192 | template <typename C> | ||
| 193 | requires constructible_from<Callback, C> | ||
| 194 | explicit stop_callback(const stop_token& st, | ||
| 195 | C&& cb) noexcept(is_nothrow_constructible_v<Callback, C>) | ||
| 196 | : m_stop_state(st.m_stop_state) { | ||
| 197 | if (m_stop_state) { | ||
| 198 | m_callback = m_stop_state->insert_callback(move(cb)); | ||
| 199 | } | ||
| 200 | } | ||
| 201 | template <typename C> | ||
| 202 | requires constructible_from<Callback, C> | ||
| 203 | explicit stop_callback(stop_token&& st, | ||
| 204 | C&& cb) noexcept(is_nothrow_constructible_v<Callback, C>) | ||
| 205 | : m_stop_state(move(st.m_stop_state)) { | ||
| 206 | if (m_stop_state) { | ||
| 207 | m_callback = m_stop_state->insert_callback(move(cb)); | ||
| 208 | } | ||
| 209 | } | ||
| 210 | ~stop_callback() { | ||
| 211 | if (m_stop_state && m_callback) { | ||
| 212 | m_stop_state->remove_callback(*m_callback); | ||
| 213 | } | ||
| 214 | } | ||
| 215 | |||
| 216 | stop_callback(const stop_callback&) = delete; | ||
| 217 | stop_callback(stop_callback&&) = delete; | ||
| 218 | stop_callback& operator=(const stop_callback&) = delete; | ||
| 219 | stop_callback& operator=(stop_callback&&) = delete; | ||
| 220 | |||
| 221 | private: | ||
| 222 | shared_ptr<polyfill::stop_state> m_stop_state; | ||
| 223 | optional<polyfill::stop_state_callbacks::const_iterator> m_callback; | ||
| 224 | }; | ||
| 225 | |||
| 226 | template <typename Callback> | ||
| 227 | stop_callback(stop_token, Callback) -> stop_callback<Callback>; | ||
| 228 | |||
| 229 | class jthread { | ||
| 230 | public: | ||
| 231 | using id = thread::id; | ||
| 232 | using native_handle_type = thread::native_handle_type; | ||
| 233 | |||
| 234 | jthread() noexcept = default; | ||
| 235 | |||
| 236 | template <typename F, typename... Args, | ||
| 237 | typename = enable_if_t<!is_same_v<remove_cvref_t<F>, jthread>>> | ||
| 238 | explicit jthread(F&& f, Args&&... args) | ||
| 239 | : m_stop_state(make_shared<polyfill::stop_state>()), | ||
| 240 | m_thread(make_thread(move(f), move(args)...)) {} | ||
| 241 | |||
| 242 | ~jthread() { | ||
| 243 | if (joinable()) { | ||
| 244 | request_stop(); | ||
| 245 | join(); | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 249 | jthread(const jthread&) = delete; | ||
| 250 | jthread(jthread&&) noexcept = default; | ||
| 251 | jthread& operator=(const jthread&) = delete; | ||
| 252 | |||
| 253 | jthread& operator=(jthread&& other) noexcept { | ||
| 254 | m_thread.swap(other.m_thread); | ||
| 255 | m_stop_state.swap(other.m_stop_state); | ||
| 256 | return *this; | ||
| 257 | } | ||
| 258 | |||
| 259 | void swap(jthread& other) noexcept { | ||
| 260 | m_thread.swap(other.m_thread); | ||
| 261 | m_stop_state.swap(other.m_stop_state); | ||
| 262 | } | ||
| 263 | [[nodiscard]] bool joinable() const noexcept { | ||
| 264 | return m_thread.joinable(); | ||
| 265 | } | ||
| 266 | void join() { | ||
| 267 | m_thread.join(); | ||
| 268 | } | ||
| 269 | void detach() { | ||
| 270 | m_thread.detach(); | ||
| 271 | m_stop_state.reset(); | ||
| 272 | } | ||
| 273 | |||
| 274 | [[nodiscard]] id get_id() const noexcept { | ||
| 275 | return m_thread.get_id(); | ||
| 276 | } | ||
| 277 | [[nodiscard]] native_handle_type native_handle() { | ||
| 278 | return m_thread.native_handle(); | ||
| 279 | } | ||
| 280 | [[nodiscard]] stop_source get_stop_source() noexcept { | ||
| 281 | return stop_source(m_stop_state); | ||
| 282 | } | ||
| 283 | [[nodiscard]] stop_token get_stop_token() const noexcept { | ||
| 284 | return stop_source(m_stop_state).get_token(); | ||
| 285 | } | ||
| 286 | bool request_stop() noexcept { | ||
| 287 | return get_stop_source().request_stop(); | ||
| 288 | } | ||
| 289 | [[nodiscard]] static unsigned int hardware_concurrency() noexcept { | ||
| 290 | return thread::hardware_concurrency(); | ||
| 291 | } | ||
| 292 | |||
| 293 | private: | ||
| 294 | template <typename F, typename... Args> | ||
| 295 | thread make_thread(F&& f, Args&&... args) { | ||
| 296 | if constexpr (is_invocable_v<decay_t<F>, stop_token, decay_t<Args>...>) { | ||
| 297 | return thread(move(f), get_stop_token(), move(args)...); | ||
| 298 | } else { | ||
| 299 | return thread(move(f), move(args)...); | ||
| 300 | } | ||
| 301 | } | ||
| 302 | |||
| 303 | shared_ptr<polyfill::stop_state> m_stop_state; | ||
| 304 | thread m_thread; | ||
| 305 | }; | ||
| 306 | |||
| 307 | } // namespace std | ||
| 308 | |||
| 309 | namespace Common { | ||
| 310 | |||
| 311 | template <typename Condvar, typename Lock, typename Pred> | ||
| 312 | void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred pred) { | ||
| 313 | if (token.stop_requested()) { | ||
| 314 | return; | ||
| 315 | } | ||
| 316 | |||
| 317 | std::stop_callback callback(token, [&] { cv.notify_all(); }); | ||
| 318 | cv.wait(lock, [&] { return pred() || token.stop_requested(); }); | ||
| 319 | } | ||
| 320 | |||
| 321 | } // namespace Common | ||
| 322 | |||
| 323 | #endif | ||
diff --git a/src/common/thread_worker.h b/src/common/thread_worker.h index 62c60f724..260ad44e4 100644 --- a/src/common/thread_worker.h +++ b/src/common/thread_worker.h | |||
| @@ -7,13 +7,13 @@ | |||
| 7 | #include <condition_variable> | 7 | #include <condition_variable> |
| 8 | #include <functional> | 8 | #include <functional> |
| 9 | #include <mutex> | 9 | #include <mutex> |
| 10 | #include <stop_token> | ||
| 11 | #include <string> | 10 | #include <string> |
| 12 | #include <thread> | 11 | #include <thread> |
| 13 | #include <type_traits> | 12 | #include <type_traits> |
| 14 | #include <vector> | 13 | #include <vector> |
| 15 | #include <queue> | 14 | #include <queue> |
| 16 | 15 | ||
| 16 | #include "common/polyfill_thread.h" | ||
| 17 | #include "common/thread.h" | 17 | #include "common/thread.h" |
| 18 | #include "common/unique_function.h" | 18 | #include "common/unique_function.h" |
| 19 | 19 | ||
| @@ -47,7 +47,8 @@ public: | |||
| 47 | if (requests.empty()) { | 47 | if (requests.empty()) { |
| 48 | wait_condition.notify_all(); | 48 | wait_condition.notify_all(); |
| 49 | } | 49 | } |
| 50 | condition.wait(lock, stop_token, [this] { return !requests.empty(); }); | 50 | Common::CondvarWait(condition, lock, stop_token, |
| 51 | [this] { return !requests.empty(); }); | ||
| 51 | if (stop_token.stop_requested()) { | 52 | if (stop_token.stop_requested()) { |
| 52 | break; | 53 | break; |
| 53 | } | 54 | } |
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h index 053798e79..2ef1da064 100644 --- a/src/common/threadsafe_queue.h +++ b/src/common/threadsafe_queue.h | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | #include <mutex> | 12 | #include <mutex> |
| 13 | #include <utility> | 13 | #include <utility> |
| 14 | 14 | ||
| 15 | #include "common/polyfill_thread.h" | ||
| 16 | |||
| 15 | namespace Common { | 17 | namespace Common { |
| 16 | template <typename T, bool with_stop_token = false> | 18 | template <typename T, bool with_stop_token = false> |
| 17 | class SPSCQueue { | 19 | class SPSCQueue { |
| @@ -97,7 +99,7 @@ public: | |||
| 97 | T PopWait(std::stop_token stop_token) { | 99 | T PopWait(std::stop_token stop_token) { |
| 98 | if (Empty()) { | 100 | if (Empty()) { |
| 99 | std::unique_lock lock{cv_mutex}; | 101 | std::unique_lock lock{cv_mutex}; |
| 100 | cv.wait(lock, stop_token, [this] { return !Empty(); }); | 102 | Common::CondvarWait(cv, lock, stop_token, [this] { return !Empty(); }); |
| 101 | } | 103 | } |
| 102 | if (stop_token.stop_requested()) { | 104 | if (stop_token.stop_requested()) { |
| 103 | return T{}; | 105 | return T{}; |
diff --git a/src/core/cpu_manager.h b/src/core/cpu_manager.h index 95ea3ef39..374367468 100644 --- a/src/core/cpu_manager.h +++ b/src/core/cpu_manager.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <thread> | 10 | #include <thread> |
| 11 | 11 | ||
| 12 | #include "common/fiber.h" | 12 | #include "common/fiber.h" |
| 13 | #include "common/polyfill_thread.h" | ||
| 13 | #include "common/thread.h" | 14 | #include "common/thread.h" |
| 14 | #include "core/hardware_properties.h" | 15 | #include "core/hardware_properties.h" |
| 15 | 16 | ||
diff --git a/src/core/debugger/debugger.cpp b/src/core/debugger/debugger.cpp index 1a8e02e6a..a9675df76 100644 --- a/src/core/debugger/debugger.cpp +++ b/src/core/debugger/debugger.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <boost/process/async_pipe.hpp> | 9 | #include <boost/process/async_pipe.hpp> |
| 10 | 10 | ||
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "common/polyfill_thread.h" | ||
| 12 | #include "common/thread.h" | 13 | #include "common/thread.h" |
| 13 | #include "core/core.h" | 14 | #include "core/core.h" |
| 14 | #include "core/debugger/debugger.h" | 15 | #include "core/debugger/debugger.h" |
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index 78e56bbbd..50303fe42 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <utility> | 7 | #include <utility> |
| 8 | 8 | ||
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "common/polyfill_ranges.h" | ||
| 10 | #include "core/crypto/aes_util.h" | 11 | #include "core/crypto/aes_util.h" |
| 11 | #include "core/crypto/ctr_encryption_layer.h" | 12 | #include "core/crypto/ctr_encryption_layer.h" |
| 12 | #include "core/crypto/key_manager.h" | 13 | #include "core/crypto/key_manager.h" |
diff --git a/src/core/frontend/applets/controller.h b/src/core/frontend/applets/controller.h index 1d2850ad5..71698df74 100644 --- a/src/core/frontend/applets/controller.h +++ b/src/core/frontend/applets/controller.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <functional> | 6 | #include <functional> |
| 7 | #include <vector> | ||
| 7 | 8 | ||
| 8 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 9 | 10 | ||
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index d004ca56a..3f83108d3 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <mutex> | 9 | #include <mutex> |
| 10 | #include <unordered_map> | 10 | #include <unordered_map> |
| 11 | #include <vector> | ||
| 11 | 12 | ||
| 12 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 13 | #include "common/input.h" | 14 | #include "common/input.h" |
diff --git a/src/core/hid/emulated_devices.h b/src/core/hid/emulated_devices.h index 4149eeced..4cdbf9dc6 100644 --- a/src/core/hid/emulated_devices.h +++ b/src/core/hid/emulated_devices.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <mutex> | 9 | #include <mutex> |
| 10 | #include <unordered_map> | 10 | #include <unordered_map> |
| 11 | #include <vector> | ||
| 11 | 12 | ||
| 12 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 13 | #include "common/input.h" | 14 | #include "common/input.h" |
diff --git a/src/core/hle/kernel/k_memory_manager.cpp b/src/core/hle/kernel/k_memory_manager.cpp index c4bf306e8..bd33571da 100644 --- a/src/core/hle/kernel/k_memory_manager.cpp +++ b/src/core/hle/kernel/k_memory_manager.cpp | |||
| @@ -225,8 +225,8 @@ Result KMemoryManager::AllocatePageGroupImpl(KPageGroup* out, size_t num_pages, | |||
| 225 | ON_RESULT_FAILURE { | 225 | ON_RESULT_FAILURE { |
| 226 | for (const auto& it : out->Nodes()) { | 226 | for (const auto& it : out->Nodes()) { |
| 227 | auto& manager = this->GetManager(it.GetAddress()); | 227 | auto& manager = this->GetManager(it.GetAddress()); |
| 228 | const size_t node_num_pages = | 228 | const size_t node_num_pages = std::min<u64>( |
| 229 | std::min(it.GetNumPages(), (manager.GetEndAddress() - it.GetAddress()) / PageSize); | 229 | it.GetNumPages(), (manager.GetEndAddress() - it.GetAddress()) / PageSize); |
| 230 | manager.Free(it.GetAddress(), node_num_pages); | 230 | manager.Free(it.GetAddress(), node_num_pages); |
| 231 | } | 231 | } |
| 232 | out->Finalize(); | 232 | out->Finalize(); |
diff --git a/src/core/hle/kernel/k_slab_heap.h b/src/core/hle/kernel/k_slab_heap.h index a8c77a7d4..68469b041 100644 --- a/src/core/hle/kernel/k_slab_heap.h +++ b/src/core/hle/kernel/k_slab_heap.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <atomic> | 6 | #include <atomic> |
| 7 | 7 | ||
| 8 | #include "common/assert.h" | 8 | #include "common/assert.h" |
| 9 | #include "common/atomic_ops.h" | ||
| 9 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 10 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 11 | #include "common/spin_lock.h" | 12 | #include "common/spin_lock.h" |
| @@ -82,16 +83,13 @@ private: | |||
| 82 | 83 | ||
| 83 | private: | 84 | private: |
| 84 | void UpdatePeakImpl(uintptr_t obj) { | 85 | void UpdatePeakImpl(uintptr_t obj) { |
| 85 | static_assert(std::atomic_ref<uintptr_t>::is_always_lock_free); | ||
| 86 | std::atomic_ref<uintptr_t> peak_ref(m_peak); | ||
| 87 | |||
| 88 | const uintptr_t alloc_peak = obj + this->GetObjectSize(); | 86 | const uintptr_t alloc_peak = obj + this->GetObjectSize(); |
| 89 | uintptr_t cur_peak = m_peak; | 87 | uintptr_t cur_peak = m_peak; |
| 90 | do { | 88 | do { |
| 91 | if (alloc_peak <= cur_peak) { | 89 | if (alloc_peak <= cur_peak) { |
| 92 | break; | 90 | break; |
| 93 | } | 91 | } |
| 94 | } while (!peak_ref.compare_exchange_strong(cur_peak, alloc_peak)); | 92 | } while (!Common::AtomicCompareAndSwap(&m_peak, alloc_peak, cur_peak, cur_peak)); |
| 95 | } | 93 | } |
| 96 | 94 | ||
| 97 | public: | 95 | public: |
diff --git a/src/core/hle/kernel/k_thread_local_page.h b/src/core/hle/kernel/k_thread_local_page.h index 5d466ace7..fe0cff084 100644 --- a/src/core/hle/kernel/k_thread_local_page.h +++ b/src/core/hle/kernel/k_thread_local_page.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/assert.h" | 10 | #include "common/assert.h" |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/intrusive_red_black_tree.h" | 12 | #include "common/intrusive_red_black_tree.h" |
| 13 | #include "common/polyfill_ranges.h" | ||
| 13 | #include "core/hle/kernel/memory_types.h" | 14 | #include "core/hle/kernel/memory_types.h" |
| 14 | #include "core/hle/kernel/slab_helpers.h" | 15 | #include "core/hle/kernel/slab_helpers.h" |
| 15 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
diff --git a/src/core/hle/kernel/service_thread.cpp b/src/core/hle/kernel/service_thread.cpp index e6e41ac34..0690f9a1c 100644 --- a/src/core/hle/kernel/service_thread.cpp +++ b/src/core/hle/kernel/service_thread.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <thread> | 7 | #include <thread> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | 9 | ||
| 10 | #include "common/polyfill_thread.h" | ||
| 10 | #include "common/scope_exit.h" | 11 | #include "common/scope_exit.h" |
| 11 | #include "common/thread.h" | 12 | #include "common/thread.h" |
| 12 | #include "core/hle/ipc_helpers.h" | 13 | #include "core/hle/ipc_helpers.h" |
diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index 3730937fe..1ea8c7fbc 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h | |||
| @@ -82,7 +82,7 @@ void SvcWrap64(Core::System& system) { | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | // Used by ControlCodeMemory | 84 | // Used by ControlCodeMemory |
| 85 | template <Result func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> | 85 | template <Result func(Core::System&, Handle, u32, VAddr, size_t, Svc::MemoryPermission)> |
| 86 | void SvcWrap64(Core::System& system) { | 86 | void SvcWrap64(Core::System& system) { |
| 87 | FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), | 87 | FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), |
| 88 | static_cast<u32>(Param(system, 1)), Param(system, 2), Param(system, 3), | 88 | static_cast<u32>(Param(system, 1)), Param(system, 2), Param(system, 3), |
| @@ -327,7 +327,7 @@ void SvcWrap64(Core::System& system) { | |||
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | // Used by CreateCodeMemory | 329 | // Used by CreateCodeMemory |
| 330 | template <Result func(Core::System&, Handle*, u64, u64)> | 330 | template <Result func(Core::System&, Handle*, VAddr, size_t)> |
| 331 | void SvcWrap64(Core::System& system) { | 331 | void SvcWrap64(Core::System& system) { |
| 332 | u32 param_1 = 0; | 332 | u32 param_1 = 0; |
| 333 | const u32 retval = func(system, ¶m_1, Param(system, 1), Param(system, 2)).raw; | 333 | const u32 retval = func(system, ¶m_1, Param(system, 1), Param(system, 2)).raw; |
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 85a3f0802..6d1084fd1 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "common/fs/file.h" | 7 | #include "common/fs/file.h" |
| 8 | #include "common/fs/path_util.h" | 8 | #include "common/fs/path_util.h" |
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "common/polyfill_ranges.h" | ||
| 10 | #include "common/string_util.h" | 11 | #include "common/string_util.h" |
| 11 | #include "common/swap.h" | 12 | #include "common/swap.h" |
| 12 | #include "core/constants.h" | 13 | #include "core/constants.h" |
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 481e0d141..97f7c6688 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/fs/file.h" | 9 | #include "common/fs/file.h" |
| 10 | #include "common/fs/fs.h" | 10 | #include "common/fs/fs.h" |
| 11 | #include "common/fs/path_util.h" | 11 | #include "common/fs/path_util.h" |
| 12 | #include "common/polyfill_ranges.h" | ||
| 12 | #include "common/settings.h" | 13 | #include "common/settings.h" |
| 13 | #include "core/hle/service/acc/profile_manager.h" | 14 | #include "core/hle/service/acc/profile_manager.h" |
| 14 | 15 | ||
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 8ea7fd760..22999c942 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -1125,7 +1125,7 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) { | |||
| 1125 | 1125 | ||
| 1126 | const u64 offset{rp.Pop<u64>()}; | 1126 | const u64 offset{rp.Pop<u64>()}; |
| 1127 | const std::vector<u8> data{ctx.ReadBuffer()}; | 1127 | const std::vector<u8> data{ctx.ReadBuffer()}; |
| 1128 | const std::size_t size{std::min(data.size(), backing.GetSize() - offset)}; | 1128 | const std::size_t size{std::min<u64>(data.size(), backing.GetSize() - offset)}; |
| 1129 | 1129 | ||
| 1130 | LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size); | 1130 | LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size); |
| 1131 | 1131 | ||
| @@ -1149,7 +1149,7 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) { | |||
| 1149 | IPC::RequestParser rp{ctx}; | 1149 | IPC::RequestParser rp{ctx}; |
| 1150 | 1150 | ||
| 1151 | const u64 offset{rp.Pop<u64>()}; | 1151 | const u64 offset{rp.Pop<u64>()}; |
| 1152 | const std::size_t size{std::min(ctx.GetWriteBufferSize(), backing.GetSize() - offset)}; | 1152 | const std::size_t size{std::min<u64>(ctx.GetWriteBufferSize(), backing.GetSize() - offset)}; |
| 1153 | 1153 | ||
| 1154 | LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size); | 1154 | LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size); |
| 1155 | 1155 | ||
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 034ee273f..3a1c231b6 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "common/bit_util.h" | 14 | #include "common/bit_util.h" |
| 15 | #include "common/common_funcs.h" | 15 | #include "common/common_funcs.h" |
| 16 | #include "common/logging/log.h" | 16 | #include "common/logging/log.h" |
| 17 | #include "common/polyfill_ranges.h" | ||
| 17 | #include "common/string_util.h" | 18 | #include "common/string_util.h" |
| 18 | #include "core/core.h" | 19 | #include "core/core.h" |
| 19 | #include "core/hle/ipc_helpers.h" | 20 | #include "core/hle/ipc_helpers.h" |
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 460bef976..9b22397db 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <vector> | 11 | #include <vector> |
| 12 | 12 | ||
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "common/polyfill_thread.h" | ||
| 14 | #include "core/hle/result.h" | 15 | #include "core/hle/result.h" |
| 15 | #include "core/hle/service/kernel_helpers.h" | 16 | #include "core/hle/service/kernel_helpers.h" |
| 16 | 17 | ||
diff --git a/src/core/internal_network/network_interface.cpp b/src/core/internal_network/network_interface.cpp index 057fd3661..7b8e510a2 100644 --- a/src/core/internal_network/network_interface.cpp +++ b/src/core/internal_network/network_interface.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/bit_cast.h" | 9 | #include "common/bit_cast.h" |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "common/polyfill_ranges.h" | ||
| 12 | #include "common/settings.h" | 13 | #include "common/settings.h" |
| 13 | #include "common/string_util.h" | 14 | #include "common/string_util.h" |
| 14 | #include "core/internal_network/network_interface.h" | 15 | #include "core/internal_network/network_interface.h" |
diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h index 7f81767f7..b5270fd0b 100644 --- a/src/input_common/drivers/gc_adapter.h +++ b/src/input_common/drivers/gc_adapter.h | |||
| @@ -5,10 +5,10 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <stop_token> | ||
| 9 | #include <string> | 8 | #include <string> |
| 10 | #include <thread> | 9 | #include <thread> |
| 11 | 10 | ||
| 11 | #include "common/polyfill_thread.h" | ||
| 12 | #include "input_common/input_engine.h" | 12 | #include "input_common/input_engine.h" |
| 13 | 13 | ||
| 14 | struct libusb_context; | 14 | struct libusb_context; |
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 98c3157a8..faf9cbdc3 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <stop_token> | ||
| 5 | #include <thread> | 4 | #include <thread> |
| 6 | #include <fmt/format.h> | 5 | #include <fmt/format.h> |
| 7 | 6 | ||
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index 286ce1cf6..72073cc23 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -3,9 +3,9 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <stop_token> | ||
| 7 | #include <thread> | 6 | #include <thread> |
| 8 | 7 | ||
| 8 | #include "common/polyfill_thread.h" | ||
| 9 | #include "common/vector_math.h" | 9 | #include "common/vector_math.h" |
| 10 | #include "input_common/input_engine.h" | 10 | #include "input_common/input_engine.h" |
| 11 | 11 | ||
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp index 21c6ed405..f3ade90da 100644 --- a/src/input_common/drivers/tas_input.cpp +++ b/src/input_common/drivers/tas_input.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <cstring> | 4 | #include <cstring> |
| 5 | #include <sstream> | ||
| 5 | #include <fmt/format.h> | 6 | #include <fmt/format.h> |
| 6 | 7 | ||
| 7 | #include "common/fs/file.h" | 8 | #include "common/fs/file.h" |
diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt index 8cd584154..ef09fe2b9 100644 --- a/src/shader_recompiler/CMakeLists.txt +++ b/src/shader_recompiler/CMakeLists.txt | |||
| @@ -255,6 +255,7 @@ else() | |||
| 255 | # Bracket depth determines maximum size of a fold expression in Clang since 9c9974c3ccb6. | 255 | # Bracket depth determines maximum size of a fold expression in Clang since 9c9974c3ccb6. |
| 256 | # And this in turns limits the size of a std::array. | 256 | # And this in turns limits the size of a std::array. |
| 257 | $<$<CXX_COMPILER_ID:Clang>:-fbracket-depth=1024> | 257 | $<$<CXX_COMPILER_ID:Clang>:-fbracket-depth=1024> |
| 258 | $<$<CXX_COMPILER_ID:AppleClang>:-fbracket-depth=1024> | ||
| 258 | ) | 259 | ) |
| 259 | endif() | 260 | endif() |
| 260 | 261 | ||
diff --git a/src/shader_recompiler/frontend/ir/opcodes.h b/src/shader_recompiler/frontend/ir/opcodes.h index e70d7745c..d155afd0f 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.h +++ b/src/shader_recompiler/frontend/ir/opcodes.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include <fmt/format.h> | 9 | #include <fmt/format.h> |
| 10 | 10 | ||
| 11 | #include "common/polyfill_ranges.h" | ||
| 11 | #include "shader_recompiler/frontend/ir/type.h" | 12 | #include "shader_recompiler/frontend/ir/type.h" |
| 12 | 13 | ||
| 13 | namespace Shader::IR { | 14 | namespace Shader::IR { |
diff --git a/src/shader_recompiler/frontend/maxwell/control_flow.cpp b/src/shader_recompiler/frontend/maxwell/control_flow.cpp index 6939692cd..dce414cb4 100644 --- a/src/shader_recompiler/frontend/maxwell/control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/control_flow.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | 9 | ||
| 10 | #include <fmt/format.h> | 10 | #include <fmt/format.h> |
| 11 | 11 | ||
| 12 | #include "common/polyfill_ranges.h" | ||
| 12 | #include "shader_recompiler/exception.h" | 13 | #include "shader_recompiler/exception.h" |
| 13 | #include "shader_recompiler/frontend/maxwell/control_flow.h" | 14 | #include "shader_recompiler/frontend/maxwell/control_flow.h" |
| 14 | #include "shader_recompiler/frontend/maxwell/decode.h" | 15 | #include "shader_recompiler/frontend/maxwell/decode.h" |
diff --git a/src/shader_recompiler/frontend/maxwell/decode.cpp b/src/shader_recompiler/frontend/maxwell/decode.cpp index 455c91470..774f65bc5 100644 --- a/src/shader_recompiler/frontend/maxwell/decode.cpp +++ b/src/shader_recompiler/frontend/maxwell/decode.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/polyfill_ranges.h" | ||
| 10 | #include "shader_recompiler/exception.h" | 11 | #include "shader_recompiler/exception.h" |
| 11 | #include "shader_recompiler/frontend/maxwell/decode.h" | 12 | #include "shader_recompiler/frontend/maxwell/decode.h" |
| 12 | #include "shader_recompiler/frontend/maxwell/opcodes.h" | 13 | #include "shader_recompiler/frontend/maxwell/opcodes.h" |
diff --git a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp index ce42475d4..80c90fe6a 100644 --- a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include <boost/intrusive/list.hpp> | 13 | #include <boost/intrusive/list.hpp> |
| 14 | 14 | ||
| 15 | #include "common/polyfill_ranges.h" | ||
| 15 | #include "shader_recompiler/environment.h" | 16 | #include "shader_recompiler/environment.h" |
| 16 | #include "shader_recompiler/frontend/ir/basic_block.h" | 17 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 17 | #include "shader_recompiler/frontend/ir/ir_emitter.h" | 18 | #include "shader_recompiler/frontend/ir/ir_emitter.h" |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_conversion_integer.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_conversion_integer.cpp index 4942878b9..85c18d942 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_conversion_integer.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_conversion_integer.cpp | |||
| @@ -176,12 +176,13 @@ void TranslateF2I(TranslatorVisitor& v, u64 insn, const IR::F16F32F64& src_a) { | |||
| 176 | (f2i.src_format == SrcFormat::F64) != (f2i.dest_format == DestFormat::I64); | 176 | (f2i.src_format == SrcFormat::F64) != (f2i.dest_format == DestFormat::I64); |
| 177 | if (special_nan_cases) { | 177 | if (special_nan_cases) { |
| 178 | if (f2i.dest_format == DestFormat::I32) { | 178 | if (f2i.dest_format == DestFormat::I32) { |
| 179 | constexpr u32 nan_value = 0x8000'0000U; | ||
| 179 | handled_special_case = true; | 180 | handled_special_case = true; |
| 180 | result = IR::U32{v.ir.Select(v.ir.FPIsNan(op_a), v.ir.Imm32(0x8000'0000U), result)}; | 181 | result = IR::U32{v.ir.Select(v.ir.FPIsNan(op_a), v.ir.Imm32(nan_value), result)}; |
| 181 | } else if (f2i.dest_format == DestFormat::I64) { | 182 | } else if (f2i.dest_format == DestFormat::I64) { |
| 183 | constexpr u64 nan_value = 0x8000'0000'0000'0000ULL; | ||
| 182 | handled_special_case = true; | 184 | handled_special_case = true; |
| 183 | result = IR::U64{ | 185 | result = IR::U64{v.ir.Select(v.ir.FPIsNan(op_a), v.ir.Imm64(nan_value), result)}; |
| 184 | v.ir.Select(v.ir.FPIsNan(op_a), v.ir.Imm64(0x8000'0000'0000'0000UL), result)}; | ||
| 185 | } | 186 | } |
| 186 | } | 187 | } |
| 187 | if (!handled_special_case && is_signed) { | 188 | if (!handled_special_case && is_signed) { |
diff --git a/src/video_core/buffer_cache/buffer_base.h b/src/video_core/buffer_cache/buffer_base.h index f9a6472cf..92d77eef2 100644 --- a/src/video_core/buffer_cache/buffer_base.h +++ b/src/video_core/buffer_cache/buffer_base.h | |||
| @@ -535,7 +535,7 @@ private: | |||
| 535 | const u64* const state_words = Array<type>(); | 535 | const u64* const state_words = Array<type>(); |
| 536 | const u64 num_query_words = size / BYTES_PER_WORD + 1; | 536 | const u64 num_query_words = size / BYTES_PER_WORD + 1; |
| 537 | const u64 word_begin = offset / BYTES_PER_WORD; | 537 | const u64 word_begin = offset / BYTES_PER_WORD; |
| 538 | const u64 word_end = std::min(word_begin + num_query_words, NumWords()); | 538 | const u64 word_end = std::min<u64>(word_begin + num_query_words, NumWords()); |
| 539 | const u64 page_limit = Common::DivCeil(offset + size, BYTES_PER_PAGE); | 539 | const u64 page_limit = Common::DivCeil(offset + size, BYTES_PER_PAGE); |
| 540 | u64 page_index = (offset / BYTES_PER_PAGE) % PAGES_PER_WORD; | 540 | u64 page_index = (offset / BYTES_PER_PAGE) % PAGES_PER_WORD; |
| 541 | for (u64 word_index = word_begin; word_index < word_end; ++word_index, page_index = 0) { | 541 | for (u64 word_index = word_begin; word_index < word_end; ++word_index, page_index = 0) { |
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 5d3a8293b..6881b34c4 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "common/literals.h" | 19 | #include "common/literals.h" |
| 20 | #include "common/lru_cache.h" | 20 | #include "common/lru_cache.h" |
| 21 | #include "common/microprofile.h" | 21 | #include "common/microprofile.h" |
| 22 | #include "common/polyfill_ranges.h" | ||
| 22 | #include "common/settings.h" | 23 | #include "common/settings.h" |
| 23 | #include "core/memory.h" | 24 | #include "core/memory.h" |
| 24 | #include "video_core/buffer_cache/buffer_base.h" | 25 | #include "video_core/buffer_cache/buffer_base.h" |
diff --git a/src/video_core/control/channel_state_cache.h b/src/video_core/control/channel_state_cache.h index 584a0c26c..cdaf4f8d5 100644 --- a/src/video_core/control/channel_state_cache.h +++ b/src/video_core/control/channel_state_cache.h | |||
| @@ -35,8 +35,6 @@ public: | |||
| 35 | explicit ChannelInfo(Tegra::Control::ChannelState& state); | 35 | explicit ChannelInfo(Tegra::Control::ChannelState& state); |
| 36 | ChannelInfo(const ChannelInfo& state) = delete; | 36 | ChannelInfo(const ChannelInfo& state) = delete; |
| 37 | ChannelInfo& operator=(const ChannelInfo&) = delete; | 37 | ChannelInfo& operator=(const ChannelInfo&) = delete; |
| 38 | ChannelInfo(ChannelInfo&& other) = default; | ||
| 39 | ChannelInfo& operator=(ChannelInfo&& other) = default; | ||
| 40 | 38 | ||
| 41 | Tegra::Engines::Maxwell3D& maxwell3d; | 39 | Tegra::Engines::Maxwell3D& maxwell3d; |
| 42 | Tegra::Engines::KeplerCompute& kepler_compute; | 40 | Tegra::Engines::KeplerCompute& kepler_compute; |
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 1bd477011..164a5252a 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp | |||
| @@ -125,7 +125,7 @@ u64 ThreadManager::PushCommand(CommandData&& command_data, bool block) { | |||
| 125 | state.queue.Push(CommandDataContainer(std::move(command_data), fence, block)); | 125 | state.queue.Push(CommandDataContainer(std::move(command_data), fence, block)); |
| 126 | 126 | ||
| 127 | if (block) { | 127 | if (block) { |
| 128 | state.cv.wait(lk, thread.get_stop_token(), [this, fence] { | 128 | Common::CondvarWait(state.cv, lk, thread.get_stop_token(), [this, fence] { |
| 129 | return fence <= state.signaled_fence.load(std::memory_order_relaxed); | 129 | return fence <= state.signaled_fence.load(std::memory_order_relaxed); |
| 130 | }); | 130 | }); |
| 131 | } | 131 | } |
diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h index 64628d3e3..c71a419c7 100644 --- a/src/video_core/gpu_thread.h +++ b/src/video_core/gpu_thread.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <thread> | 10 | #include <thread> |
| 11 | #include <variant> | 11 | #include <variant> |
| 12 | 12 | ||
| 13 | #include "common/polyfill_thread.h" | ||
| 13 | #include "common/threadsafe_queue.h" | 14 | #include "common/threadsafe_queue.h" |
| 14 | #include "video_core/framebuffer_config.h" | 15 | #include "video_core/framebuffer_config.h" |
| 15 | 16 | ||
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index cfd872a40..b6907463c 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h | |||
| @@ -6,8 +6,8 @@ | |||
| 6 | #include <functional> | 6 | #include <functional> |
| 7 | #include <optional> | 7 | #include <optional> |
| 8 | #include <span> | 8 | #include <span> |
| 9 | #include <stop_token> | ||
| 10 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/polyfill_thread.h" | ||
| 11 | #include "video_core/engines/fermi_2d.h" | 11 | #include "video_core/engines/fermi_2d.h" |
| 12 | #include "video_core/gpu.h" | 12 | #include "video_core/gpu.h" |
| 13 | 13 | ||
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp index 1663e277d..e2e3dac34 100644 --- a/src/video_core/renderer_opengl/gl_device.cpp +++ b/src/video_core/renderer_opengl/gl_device.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | #include "common/literals.h" | 15 | #include "common/literals.h" |
| 16 | #include "common/logging/log.h" | 16 | #include "common/logging/log.h" |
| 17 | #include "common/polyfill_ranges.h" | ||
| 17 | #include "common/settings.h" | 18 | #include "common/settings.h" |
| 18 | #include "shader_recompiler/stage.h" | 19 | #include "shader_recompiler/stage.h" |
| 19 | #include "video_core/renderer_opengl/gl_device.h" | 20 | #include "video_core/renderer_opengl/gl_device.h" |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h index 89f181fe3..53ffea904 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_cache.h | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <filesystem> | 6 | #include <filesystem> |
| 7 | #include <stop_token> | ||
| 8 | #include <unordered_map> | 7 | #include <unordered_map> |
| 9 | 8 | ||
| 10 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index 98cc26679..f3f08b42c 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "common/bit_cast.h" | 7 | #include "common/bit_cast.h" |
| 8 | #include "common/cityhash.h" | 8 | #include "common/cityhash.h" |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/polyfill_ranges.h" | ||
| 10 | #include "video_core/renderer_vulkan/fixed_pipeline_state.h" | 11 | #include "video_core/renderer_vulkan/fixed_pipeline_state.h" |
| 11 | #include "video_core/renderer_vulkan/vk_state_tracker.h" | 12 | #include "video_core/renderer_vulkan/vk_state_tracker.h" |
| 12 | 13 | ||
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index 89426121f..6e5abade4 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/assert.h" | 10 | #include "common/assert.h" |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/math_util.h" | 12 | #include "common/math_util.h" |
| 13 | #include "common/polyfill_ranges.h" | ||
| 13 | #include "common/settings.h" | 14 | #include "common/settings.h" |
| 14 | #include "core/core.h" | 15 | #include "core/core.h" |
| 15 | #include "core/frontend/emu_window.h" | 16 | #include "core/frontend/emu_window.h" |
diff --git a/src/video_core/renderer_vulkan/vk_descriptor_pool.cpp b/src/video_core/renderer_vulkan/vk_descriptor_pool.cpp index c7196b64e..b5ae6443c 100644 --- a/src/video_core/renderer_vulkan/vk_descriptor_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_descriptor_pool.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/polyfill_ranges.h" | ||
| 10 | #include "video_core/renderer_vulkan/vk_descriptor_pool.h" | 11 | #include "video_core/renderer_vulkan/vk_descriptor_pool.h" |
| 11 | #include "video_core/renderer_vulkan/vk_resource_pool.h" | 12 | #include "video_core/renderer_vulkan/vk_resource_pool.h" |
| 12 | #include "video_core/renderer_vulkan/vk_scheduler.h" | 13 | #include "video_core/renderer_vulkan/vk_scheduler.h" |
diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.h b/src/video_core/renderer_vulkan/vk_master_semaphore.h index 362ed579a..689f02ea5 100644 --- a/src/video_core/renderer_vulkan/vk_master_semaphore.h +++ b/src/video_core/renderer_vulkan/vk_master_semaphore.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <thread> | 7 | #include <thread> |
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/polyfill_thread.h" | ||
| 10 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 11 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
| 11 | 12 | ||
| 12 | namespace Vulkan { | 13 | namespace Vulkan { |
diff --git a/src/video_core/renderer_vulkan/vk_render_pass_cache.h b/src/video_core/renderer_vulkan/vk_render_pass_cache.h index dc21b7e69..91ad4bf57 100644 --- a/src/video_core/renderer_vulkan/vk_render_pass_cache.h +++ b/src/video_core/renderer_vulkan/vk_render_pass_cache.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | namespace Vulkan { | 12 | namespace Vulkan { |
| 13 | 13 | ||
| 14 | struct RenderPassKey { | 14 | struct RenderPassKey { |
| 15 | auto operator<=>(const RenderPassKey&) const noexcept = default; | 15 | bool operator==(const RenderPassKey&) const noexcept = default; |
| 16 | 16 | ||
| 17 | std::array<VideoCore::Surface::PixelFormat, 8> color_formats; | 17 | std::array<VideoCore::Surface::PixelFormat, 8> color_formats; |
| 18 | VideoCore::Surface::PixelFormat depth_format; | 18 | VideoCore::Surface::PixelFormat depth_format; |
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index 4a7b633b7..c09fb3e98 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp | |||
| @@ -145,7 +145,7 @@ void Scheduler::WorkerThread(std::stop_token stop_token) { | |||
| 145 | if (work_queue.empty()) { | 145 | if (work_queue.empty()) { |
| 146 | wait_cv.notify_all(); | 146 | wait_cv.notify_all(); |
| 147 | } | 147 | } |
| 148 | work_cv.wait(lock, stop_token, [this] { return !work_queue.empty(); }); | 148 | Common::CondvarWait(work_cv, lock, stop_token, [&] { return !work_queue.empty(); }); |
| 149 | if (stop_token.stop_requested()) { | 149 | if (stop_token.stop_requested()) { |
| 150 | continue; | 150 | continue; |
| 151 | } | 151 | } |
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index 929216749..3858c506c 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include "common/alignment.h" | 13 | #include "common/alignment.h" |
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "common/polyfill_thread.h" | ||
| 15 | #include "video_core/renderer_vulkan/vk_master_semaphore.h" | 16 | #include "video_core/renderer_vulkan/vk_master_semaphore.h" |
| 16 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 17 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
| 17 | 18 | ||
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index 706d9ba74..d7be417f5 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | 8 | ||
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "common/polyfill_ranges.h" | ||
| 10 | #include "common/settings.h" | 11 | #include "common/settings.h" |
| 11 | #include "core/core.h" | 12 | #include "core/core.h" |
| 12 | #include "video_core/renderer_vulkan/vk_scheduler.h" | 13 | #include "video_core/renderer_vulkan/vk_scheduler.h" |
diff --git a/src/video_core/shader_cache.h b/src/video_core/shader_cache.h index a4391202d..f3cc4c70b 100644 --- a/src/video_core/shader_cache.h +++ b/src/video_core/shader_cache.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <vector> | 12 | #include <vector> |
| 13 | 13 | ||
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "common/polyfill_ranges.h" | ||
| 15 | #include "video_core/control/channel_state_cache.h" | 16 | #include "video_core/control/channel_state_cache.h" |
| 16 | #include "video_core/rasterizer_interface.h" | 17 | #include "video_core/rasterizer_interface.h" |
| 17 | #include "video_core/shader_environment.h" | 18 | #include "video_core/shader_environment.h" |
diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp index f24f320b6..958810747 100644 --- a/src/video_core/shader_environment.cpp +++ b/src/video_core/shader_environment.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "common/fs/fs.h" | 15 | #include "common/fs/fs.h" |
| 16 | #include "common/fs/path_util.h" | 16 | #include "common/fs/path_util.h" |
| 17 | #include "common/logging/log.h" | 17 | #include "common/logging/log.h" |
| 18 | #include "common/polyfill_ranges.h" | ||
| 18 | #include "shader_recompiler/environment.h" | 19 | #include "shader_recompiler/environment.h" |
| 19 | #include "video_core/engines/kepler_compute.h" | 20 | #include "video_core/engines/kepler_compute.h" |
| 20 | #include "video_core/memory_manager.h" | 21 | #include "video_core/memory_manager.h" |
diff --git a/src/video_core/shader_environment.h b/src/video_core/shader_environment.h index bb55b029f..1342fab1e 100644 --- a/src/video_core/shader_environment.h +++ b/src/video_core/shader_environment.h | |||
| @@ -10,12 +10,12 @@ | |||
| 10 | #include <memory> | 10 | #include <memory> |
| 11 | #include <optional> | 11 | #include <optional> |
| 12 | #include <span> | 12 | #include <span> |
| 13 | #include <stop_token> | ||
| 14 | #include <type_traits> | 13 | #include <type_traits> |
| 15 | #include <unordered_map> | 14 | #include <unordered_map> |
| 16 | #include <vector> | 15 | #include <vector> |
| 17 | 16 | ||
| 18 | #include "common/common_types.h" | 17 | #include "common/common_types.h" |
| 18 | #include "common/polyfill_thread.h" | ||
| 19 | #include "common/unique_function.h" | 19 | #include "common/unique_function.h" |
| 20 | #include "shader_recompiler/environment.h" | 20 | #include "shader_recompiler/environment.h" |
| 21 | #include "video_core/engines/maxwell_3d.h" | 21 | #include "video_core/engines/maxwell_3d.h" |
diff --git a/src/video_core/texture_cache/formatter.cpp b/src/video_core/texture_cache/formatter.cpp index ee4f2d406..418890126 100644 --- a/src/video_core/texture_cache/formatter.cpp +++ b/src/video_core/texture_cache/formatter.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <algorithm> | 4 | #include <algorithm> |
| 5 | #include <string> | 5 | #include <string> |
| 6 | 6 | ||
| 7 | #include "common/polyfill_ranges.h" | ||
| 7 | #include "video_core/texture_cache/formatter.h" | 8 | #include "video_core/texture_cache/formatter.h" |
| 8 | #include "video_core/texture_cache/image_base.h" | 9 | #include "video_core/texture_cache/image_base.h" |
| 9 | #include "video_core/texture_cache/image_info.h" | 10 | #include "video_core/texture_cache/image_info.h" |
diff --git a/src/video_core/texture_cache/render_targets.h b/src/video_core/texture_cache/render_targets.h index 1efbd6507..0829d773a 100644 --- a/src/video_core/texture_cache/render_targets.h +++ b/src/video_core/texture_cache/render_targets.h | |||
| @@ -13,7 +13,7 @@ namespace VideoCommon { | |||
| 13 | 13 | ||
| 14 | /// Framebuffer properties used to lookup a framebuffer | 14 | /// Framebuffer properties used to lookup a framebuffer |
| 15 | struct RenderTargets { | 15 | struct RenderTargets { |
| 16 | constexpr auto operator<=>(const RenderTargets&) const noexcept = default; | 16 | constexpr bool operator==(const RenderTargets&) const noexcept = default; |
| 17 | 17 | ||
| 18 | constexpr bool Contains(std::span<const ImageViewId> elements) const noexcept { | 18 | constexpr bool Contains(std::span<const ImageViewId> elements) const noexcept { |
| 19 | const auto contains = [elements](ImageViewId item) { | 19 | const auto contains = [elements](ImageViewId item) { |
diff --git a/src/video_core/texture_cache/slot_vector.h b/src/video_core/texture_cache/slot_vector.h index 46e8a86e6..1e2aad76a 100644 --- a/src/video_core/texture_cache/slot_vector.h +++ b/src/video_core/texture_cache/slot_vector.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include "common/assert.h" | 13 | #include "common/assert.h" |
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "common/polyfill_ranges.h" | ||
| 15 | 16 | ||
| 16 | namespace VideoCommon { | 17 | namespace VideoCommon { |
| 17 | 18 | ||
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 9db7195bf..587339a31 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "common/hash.h" | 16 | #include "common/hash.h" |
| 17 | #include "common/literals.h" | 17 | #include "common/literals.h" |
| 18 | #include "common/lru_cache.h" | 18 | #include "common/lru_cache.h" |
| 19 | #include "common/polyfill_ranges.h" | ||
| 19 | #include "video_core/compatible_formats.h" | 20 | #include "video_core/compatible_formats.h" |
| 20 | #include "video_core/control/channel_state_cache.h" | 21 | #include "video_core/control/channel_state_cache.h" |
| 21 | #include "video_core/delayed_destruction_ring.h" | 22 | #include "video_core/delayed_destruction_ring.h" |
| @@ -60,8 +61,6 @@ public: | |||
| 60 | TextureCacheChannelInfo(Tegra::Control::ChannelState& state) noexcept; | 61 | TextureCacheChannelInfo(Tegra::Control::ChannelState& state) noexcept; |
| 61 | TextureCacheChannelInfo(const TextureCacheChannelInfo& state) = delete; | 62 | TextureCacheChannelInfo(const TextureCacheChannelInfo& state) = delete; |
| 62 | TextureCacheChannelInfo& operator=(const TextureCacheChannelInfo&) = delete; | 63 | TextureCacheChannelInfo& operator=(const TextureCacheChannelInfo&) = delete; |
| 63 | TextureCacheChannelInfo(TextureCacheChannelInfo&& other) noexcept = default; | ||
| 64 | TextureCacheChannelInfo& operator=(TextureCacheChannelInfo&& other) noexcept = default; | ||
| 65 | 64 | ||
| 66 | DescriptorTable<TICEntry> graphics_image_table{gpu_memory}; | 65 | DescriptorTable<TICEntry> graphics_image_table{gpu_memory}; |
| 67 | DescriptorTable<TSCEntry> graphics_sampler_table{gpu_memory}; | 66 | DescriptorTable<TSCEntry> graphics_sampler_table{gpu_memory}; |
diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp index 69a32819a..e8d7c7863 100644 --- a/src/video_core/textures/astc.cpp +++ b/src/video_core/textures/astc.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | #include "common/alignment.h" | 16 | #include "common/alignment.h" |
| 17 | #include "common/common_types.h" | 17 | #include "common/common_types.h" |
| 18 | #include "common/polyfill_ranges.h" | ||
| 18 | #include "common/thread_worker.h" | 19 | #include "common/thread_worker.h" |
| 19 | #include "video_core/textures/astc.h" | 20 | #include "video_core/textures/astc.h" |
| 20 | 21 | ||
diff --git a/src/video_core/transform_feedback.cpp b/src/video_core/transform_feedback.cpp index 45071185a..155599316 100644 --- a/src/video_core/transform_feedback.cpp +++ b/src/video_core/transform_feedback.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | #include "common/alignment.h" | 8 | #include "common/alignment.h" |
| 9 | #include "common/assert.h" | 9 | #include "common/assert.h" |
| 10 | #include "common/polyfill_ranges.h" | ||
| 10 | #include "shader_recompiler/shader_info.h" | 11 | #include "shader_recompiler/shader_info.h" |
| 11 | #include "video_core/transform_feedback.h" | 12 | #include "video_core/transform_feedback.h" |
| 12 | 13 | ||
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index a16a8275b..652329c38 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include "common/assert.h" | 13 | #include "common/assert.h" |
| 14 | #include "common/literals.h" | 14 | #include "common/literals.h" |
| 15 | #include "common/polyfill_ranges.h" | ||
| 15 | #include "common/settings.h" | 16 | #include "common/settings.h" |
| 16 | #include "video_core/vulkan_common/nsight_aftermath_tracker.h" | 17 | #include "video_core/vulkan_common/nsight_aftermath_tracker.h" |
| 17 | #include "video_core/vulkan_common/vulkan_device.h" | 18 | #include "video_core/vulkan_common/vulkan_device.h" |
diff --git a/src/video_core/vulkan_common/vulkan_instance.cpp b/src/video_core/vulkan_common/vulkan_instance.cpp index 35e073e16..562039b56 100644 --- a/src/video_core/vulkan_common/vulkan_instance.cpp +++ b/src/video_core/vulkan_common/vulkan_instance.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/dynamic_library.h" | 10 | #include "common/dynamic_library.h" |
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "common/polyfill_ranges.h" | ||
| 12 | #include "core/frontend/emu_window.h" | 13 | #include "core/frontend/emu_window.h" |
| 13 | #include "video_core/vulkan_common/vulkan_instance.h" | 14 | #include "video_core/vulkan_common/vulkan_instance.h" |
| 14 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 15 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp index 6442898bd..1732866e0 100644 --- a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp +++ b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "common/logging/log.h" | 14 | #include "common/logging/log.h" |
| 15 | #include "common/polyfill_ranges.h" | ||
| 15 | #include "video_core/vulkan_common/vulkan_device.h" | 16 | #include "video_core/vulkan_common/vulkan_device.h" |
| 16 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" | 17 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" |
| 17 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 18 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index ccf1c50f4..a6658a26f 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -118,7 +118,7 @@ void EmuThread::run() { | |||
| 118 | } | 118 | } |
| 119 | } else { | 119 | } else { |
| 120 | std::unique_lock lock{running_mutex}; | 120 | std::unique_lock lock{running_mutex}; |
| 121 | running_cv.wait(lock, stop_token, [this] { return IsRunning(); }); | 121 | Common::CondvarWait(running_cv, lock, stop_token, [&] { return IsRunning(); }); |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | 124 | ||
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 4a01481cd..ca4aee088 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <QTouchEvent> | 14 | #include <QTouchEvent> |
| 15 | #include <QWidget> | 15 | #include <QWidget> |
| 16 | 16 | ||
| 17 | #include "common/polyfill_thread.h" | ||
| 17 | #include "common/thread.h" | 18 | #include "common/thread.h" |
| 18 | #include "core/frontend/emu_window.h" | 19 | #include "core/frontend/emu_window.h" |
| 19 | 20 | ||
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index c21153560..4f693b339 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -2850,6 +2850,7 @@ void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_tex | |||
| 2850 | } | 2850 | } |
| 2851 | 2851 | ||
| 2852 | void GMainWindow::OnMenuReportCompatibility() { | 2852 | void GMainWindow::OnMenuReportCompatibility() { |
| 2853 | #if defined(ARCHITECTURE_x86_64) && !defined(__APPLE__) | ||
| 2853 | const auto& caps = Common::GetCPUCaps(); | 2854 | const auto& caps = Common::GetCPUCaps(); |
| 2854 | const bool has_fma = caps.fma || caps.fma4; | 2855 | const bool has_fma = caps.fma || caps.fma4; |
| 2855 | const auto processor_count = std::thread::hardware_concurrency(); | 2856 | const auto processor_count = std::thread::hardware_concurrency(); |
| @@ -2876,6 +2877,11 @@ void GMainWindow::OnMenuReportCompatibility() { | |||
| 2876 | "> " | 2877 | "> " |
| 2877 | "Web.")); | 2878 | "Web.")); |
| 2878 | } | 2879 | } |
| 2880 | #else | ||
| 2881 | QMessageBox::critical(this, tr("Hardware requirements not met"), | ||
| 2882 | tr("Your system does not meet the recommended hardware requirements. " | ||
| 2883 | "Compatibility reporting has been disabled.")); | ||
| 2884 | #endif | ||
| 2879 | } | 2885 | } |
| 2880 | 2886 | ||
| 2881 | void GMainWindow::OpenURL(const QUrl& url) { | 2887 | void GMainWindow::OpenURL(const QUrl& url) { |
diff --git a/src/yuzu/multiplayer/chat_room.h b/src/yuzu/multiplayer/chat_room.h index 01c70fad0..dd71ea4cd 100644 --- a/src/yuzu/multiplayer/chat_room.h +++ b/src/yuzu/multiplayer/chat_room.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <unordered_map> | ||
| 7 | #include <unordered_set> | 8 | #include <unordered_set> |
| 8 | #include <QDialog> | 9 | #include <QDialog> |
| 9 | #include <QSortFilterProxyModel> | 10 | #include <QSortFilterProxyModel> |