From 73666fb2622a5f6a7ab9f92c9a46ce2e215c4e83 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Fri, 24 Sep 2021 01:21:07 -0400 Subject: [PATCH] general: Update style to clang-format-12 --- src/common/alignment.h | 21 ++++++++++----- src/common/div_ceil.h | 8 +++--- src/common/intrusive_red_black_tree.h | 17 ++++++------ src/common/vector_math.h | 4 +-- src/core/hle/kernel/k_priority_queue.h | 27 +++++++------------ src/core/hle/kernel/k_scheduler.h | 2 +- src/core/hle/kernel/k_scoped_lock.h | 15 +++++------ .../k_scoped_scheduler_lock_and_sleep.h | 2 +- src/input_common/main.cpp | 4 +-- src/shader_recompiler/object_pool.h | 6 +++-- .../renderer_vulkan/renderer_vulkan.cpp | 13 +++------ .../renderer_vulkan/vk_graphics_pipeline.cpp | 5 ++-- src/video_core/texture_cache/slot_vector.h | 4 +-- 13 files changed, 62 insertions(+), 66 deletions(-) diff --git a/src/common/alignment.h b/src/common/alignment.h index 32d796ffa..1b56569d1 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h @@ -9,41 +9,48 @@ namespace Common { template -requires std::is_unsigned_v[[nodiscard]] constexpr T AlignUp(T value, size_t size) { +requires std::is_unsigned_v +[[nodiscard]] constexpr T AlignUp(T value, size_t size) { auto mod{static_cast(value % size)}; value -= mod; return static_cast(mod == T{0} ? value : value + size); } template -requires std::is_unsigned_v[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) { +requires std::is_unsigned_v +[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) { return static_cast((value + ((1ULL << align_log2) - 1)) >> align_log2 << align_log2); } template -requires std::is_unsigned_v[[nodiscard]] constexpr T AlignDown(T value, size_t size) { +requires std::is_unsigned_v +[[nodiscard]] constexpr T AlignDown(T value, size_t size) { return static_cast(value - value % size); } template -requires std::is_unsigned_v[[nodiscard]] constexpr bool Is4KBAligned(T value) { +requires std::is_unsigned_v +[[nodiscard]] constexpr bool Is4KBAligned(T value) { return (value & 0xFFF) == 0; } template -requires std::is_unsigned_v[[nodiscard]] constexpr bool IsWordAligned(T value) { +requires std::is_unsigned_v +[[nodiscard]] constexpr bool IsWordAligned(T value) { return (value & 0b11) == 0; } template -requires std::is_integral_v[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) { +requires std::is_integral_v +[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) { using U = typename std::make_unsigned_t; const U mask = static_cast(alignment - 1); return (value & mask) == 0; } template -requires std::is_integral_v[[nodiscard]] constexpr T DivideUp(T x, U y) { +requires std::is_integral_v +[[nodiscard]] constexpr T DivideUp(T x, U y) { return (x + (y - 1)) / y; } diff --git a/src/common/div_ceil.h b/src/common/div_ceil.h index 95e1489a9..e1db35464 100644 --- a/src/common/div_ceil.h +++ b/src/common/div_ceil.h @@ -11,15 +11,15 @@ namespace Common { /// Ceiled integer division. template -requires std::is_integral_v&& std::is_unsigned_v[[nodiscard]] constexpr N DivCeil(N number, - D divisor) { +requires std::is_integral_v && std::is_unsigned_v +[[nodiscard]] constexpr N DivCeil(N number, D divisor) { return static_cast((static_cast(number) + divisor - 1) / divisor); } /// Ceiled integer division with logarithmic divisor in base 2 template -requires std::is_integral_v&& std::is_unsigned_v[[nodiscard]] constexpr N DivCeilLog2( - N value, D alignment_log2) { +requires std::is_integral_v && std::is_unsigned_v +[[nodiscard]] constexpr N DivCeilLog2(N value, D alignment_log2) { return static_cast((static_cast(value) + (D(1) << alignment_log2) - 1) >> alignment_log2); } diff --git a/src/common/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h index 1f696fe80..3173cc449 100644 --- a/src/common/intrusive_red_black_tree.h +++ b/src/common/intrusive_red_black_tree.h @@ -235,20 +235,19 @@ public: template concept HasLightCompareType = requires { - { std::is_same::value } - ->std::convertible_to; + { std::is_same::value } -> std::convertible_to; }; namespace impl { -template -consteval auto* GetLightCompareType() { - if constexpr (HasLightCompareType) { - return static_cast(nullptr); - } else { - return static_cast(nullptr); + template + consteval auto* GetLightCompareType() { + if constexpr (HasLightCompareType) { + return static_cast(nullptr); + } else { + return static_cast(nullptr); + } } -} } // namespace impl diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 22dba3c2d..ba7c363c1 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -667,8 +667,8 @@ template // linear interpolation via float: 0.0=begin, 1.0=end template -[[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{}) Lerp(const X& begin, const X& end, - const float t) { +[[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{}) + Lerp(const X& begin, const X& end, const float t) { return begin * (1.f - t) + end * t; } diff --git a/src/core/hle/kernel/k_priority_queue.h b/src/core/hle/kernel/k_priority_queue.h index 4aa669d95..f4d71ad7e 100644 --- a/src/core/hle/kernel/k_priority_queue.h +++ b/src/core/hle/kernel/k_priority_queue.h @@ -22,12 +22,10 @@ class KThread; template concept KPriorityQueueAffinityMask = !std::is_reference_v && requires(T & t) { - { t.GetAffinityMask() } - ->Common::ConvertibleTo; + { t.GetAffinityMask() } -> Common::ConvertibleTo; {t.SetAffinityMask(0)}; - { t.GetAffinity(0) } - ->std::same_as; + { t.GetAffinity(0) } -> std::same_as; {t.SetAffinity(0, false)}; {t.SetAll()}; }; @@ -38,25 +36,20 @@ concept KPriorityQueueMember = !std::is_reference_v && requires(T & t) { {(typename T::QueueEntry()).Initialize()}; {(typename T::QueueEntry()).SetPrev(std::addressof(t))}; {(typename T::QueueEntry()).SetNext(std::addressof(t))}; - { (typename T::QueueEntry()).GetNext() } - ->std::same_as; - { (typename T::QueueEntry()).GetPrev() } - ->std::same_as; - { t.GetPriorityQueueEntry(0) } - ->std::same_as; + { (typename T::QueueEntry()).GetNext() } -> std::same_as; + { (typename T::QueueEntry()).GetPrev() } -> std::same_as; + { t.GetPriorityQueueEntry(0) } -> std::same_as; {t.GetAffinityMask()}; - { std::remove_cvref_t() } - ->KPriorityQueueAffinityMask; + { std::remove_cvref_t() } -> KPriorityQueueAffinityMask; - { t.GetActiveCore() } - ->Common::ConvertibleTo; - { t.GetPriority() } - ->Common::ConvertibleTo; + { t.GetActiveCore() } -> Common::ConvertibleTo; + { t.GetPriority() } -> Common::ConvertibleTo; }; template -requires KPriorityQueueMember class KPriorityQueue { +requires KPriorityQueueMember +class KPriorityQueue { public: using AffinityMaskType = std::remove_cv_t< std::remove_reference_t().GetAffinityMask())>>; diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index 12cfae919..c8ccc1ae4 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h @@ -197,7 +197,7 @@ private: class [[nodiscard]] KScopedSchedulerLock : KScopedLock { public: - explicit KScopedSchedulerLock(KernelCore & kernel); + explicit KScopedSchedulerLock(KernelCore& kernel); ~KScopedSchedulerLock(); }; diff --git a/src/core/hle/kernel/k_scoped_lock.h b/src/core/hle/kernel/k_scoped_lock.h index 72c3b0252..4fb180fc6 100644 --- a/src/core/hle/kernel/k_scoped_lock.h +++ b/src/core/hle/kernel/k_scoped_lock.h @@ -13,19 +13,18 @@ namespace Kernel { template concept KLockable = !std::is_reference_v && requires(T & t) { - { t.Lock() } - ->std::same_as; - { t.Unlock() } - ->std::same_as; + { t.Lock() } -> std::same_as; + { t.Unlock() } -> std::same_as; }; template -requires KLockable class [[nodiscard]] KScopedLock { +requires KLockable +class [[nodiscard]] KScopedLock { public: - explicit KScopedLock(T * l) : lock_ptr(l) { + explicit KScopedLock(T* l) : lock_ptr(l) { this->lock_ptr->Lock(); } - explicit KScopedLock(T & l) : KScopedLock(std::addressof(l)) {} + explicit KScopedLock(T& l) : KScopedLock(std::addressof(l)) {} ~KScopedLock() { this->lock_ptr->Unlock(); @@ -34,7 +33,7 @@ public: KScopedLock(const KScopedLock&) = delete; KScopedLock& operator=(const KScopedLock&) = delete; - KScopedLock(KScopedLock &&) = delete; + KScopedLock(KScopedLock&&) = delete; KScopedLock& operator=(KScopedLock&&) = delete; private: diff --git a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h index a86af56dd..f6c75f2d9 100644 --- a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h +++ b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h @@ -17,7 +17,7 @@ namespace Kernel { class [[nodiscard]] KScopedSchedulerLockAndSleep { public: - explicit KScopedSchedulerLockAndSleep(KernelCore & kernel_, KThread * t, s64 timeout) + explicit KScopedSchedulerLockAndSleep(KernelCore& kernel_, KThread* t, s64 timeout) : kernel(kernel_), thread(t), timeout_tick(timeout) { // Lock the scheduler. kernel.GlobalSchedulerContext().scheduler_lock.Lock(); diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 18d7d8817..f3907c65a 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -346,8 +346,8 @@ void InputSubsystem::ReloadInputDevices() { impl->udp->ReloadSockets(); } -std::vector> InputSubsystem::GetPollers([ - [maybe_unused]] Polling::DeviceType type) const { +std::vector> InputSubsystem::GetPollers( + [[maybe_unused]] Polling::DeviceType type) const { #ifdef HAVE_SDL2 return impl->sdl->GetPollers(type); #else diff --git a/src/shader_recompiler/object_pool.h b/src/shader_recompiler/object_pool.h index f3b12d04b..a12ddcc8f 100644 --- a/src/shader_recompiler/object_pool.h +++ b/src/shader_recompiler/object_pool.h @@ -11,14 +11,16 @@ namespace Shader { template -requires std::is_destructible_v class ObjectPool { +requires std::is_destructible_v +class ObjectPool { public: explicit ObjectPool(size_t chunk_size = 8192) : new_chunk_size{chunk_size} { node = &chunks.emplace_back(new_chunk_size); } template - requires std::is_constructible_v[[nodiscard]] T* Create(Args&&... args) { + requires std::is_constructible_v + [[nodiscard]] T* Create(Args&&... args) { return std::construct_at(Memory(), std::forward(args)...); } diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index adb6b7a3b..74822814d 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -97,19 +97,14 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_, Core::Frontend::EmuWindow& emu_window, Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, std::unique_ptr context_) try - : RendererBase(emu_window, std::move(context_)), - telemetry_session(telemetry_session_), - cpu_memory(cpu_memory_), - gpu(gpu_), - library(OpenLibrary()), + : RendererBase(emu_window, std::move(context_)), telemetry_session(telemetry_session_), + cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary()), instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, true, Settings::values.renderer_debug.GetValue())), debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), surface(CreateSurface(instance, render_window)), - device(CreateDevice(instance, dld, *surface)), - memory_allocator(device, false), - state_tracker(gpu), - scheduler(device, state_tracker), + device(CreateDevice(instance, dld, *surface)), memory_allocator(device, false), + state_tracker(gpu), scheduler(device, state_tracker), swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width, render_window.GetFramebufferLayout().height, false), blit_screen(cpu_memory, render_window, device, memory_allocator, swapchain, scheduler, diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 7c0f91007..11cd41ad7 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -507,8 +507,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { vertex_attributes.push_back({ .location = static_cast(index), .binding = 0, - .format = type == 1 ? VK_FORMAT_R32_SFLOAT - : type == 2 ? VK_FORMAT_R32_SINT : VK_FORMAT_R32_UINT, + .format = type == 1 ? VK_FORMAT_R32_SFLOAT + : type == 2 ? VK_FORMAT_R32_SINT + : VK_FORMAT_R32_UINT, .offset = 0, }); } diff --git a/src/video_core/texture_cache/slot_vector.h b/src/video_core/texture_cache/slot_vector.h index 74cd3c9d8..50df06409 100644 --- a/src/video_core/texture_cache/slot_vector.h +++ b/src/video_core/texture_cache/slot_vector.h @@ -31,8 +31,8 @@ struct SlotId { }; template -requires std::is_nothrow_move_assignable_v&& - std::is_nothrow_move_constructible_v class SlotVector { +requires std::is_nothrow_move_assignable_v && std::is_nothrow_move_constructible_v +class SlotVector { public: class Iterator { friend SlotVector;