From e5a954617bba504617ae9c645f7835ab348c6d88 Mon Sep 17 00:00:00 2001 From: Levi Akatsuki Date: Tue, 12 Mar 2024 04:30:44 +0000 Subject: [PATCH] Improved Addons Manager --- .gitignore | 1 + .gitlab-ci.yml | 1 + src/audio_core/in/audio_in.cpp | 4 +- src/audio_core/in/audio_in_system.cpp | 4 +- src/audio_core/out/audio_out.cpp | 4 +- src/audio_core/out/audio_out_system.cpp | 4 +- .../renderer/behavior/info_updater.cpp | 7 +- .../renderer/memory/pool_mapper.cpp | 4 +- src/common/address_space.h | 3 +- src/common/concepts.h | 6 +- src/common/expected.h | 8 +- src/common/intrusive_red_black_tree.h | 6 +- src/common/multi_level_page_table.h | 8 +- src/common/polyfill_ranges.h | 6 +- src/common/tree.h | 6 +- src/common/vector_math.h | 12 +- src/common/virtual_buffer.h | 4 +- src/common/x64/native_clock.cpp | 4 +- src/core/arm/dynarmic/arm_dynarmic_32.cpp | 4 +- src/core/arm/dynarmic/arm_dynarmic_64.cpp | 4 +- src/core/file_sys/card_image.cpp | 4 +- src/core/file_sys/fs_path_utility.h | 8 +- src/core/file_sys/patch_manager.cpp | 12 + src/core/file_sys/patch_manager.h | 2 + src/core/file_sys/submission_package.cpp | 6 +- src/core/file_sys/xts_archive.cpp | 8 +- src/core/hle/kernel/k_auto_object.h | 16 +- src/core/hle/kernel/k_memory_layout.cpp | 4 +- src/core/hle/kernel/k_priority_queue.h | 48 +- src/core/hle/kernel/k_scoped_lock.h | 9 +- src/core/hle/result.h | 8 +- src/core/hle/service/acc/acc.cpp | 4 +- .../service/am/frontend/applet_cabinet.cpp | 5 +- .../service/am/service/application_proxy.cpp | 4 +- .../am/service/library_applet_creator.cpp | 4 +- .../am/service/library_applet_proxy.cpp | 4 +- .../service/am/service/self_controller.cpp | 4 +- .../am/service/system_applet_proxy.cpp | 4 +- .../service/am/service/window_controller.cpp | 4 +- .../service/aoc/purchase_event_manager.cpp | 4 +- src/core/hle/service/audio/audio_in.cpp | 5 +- .../hle/service/audio/audio_in_manager.cpp | 4 +- src/core/hle/service/audio/audio_renderer.cpp | 4 +- .../bcat/news/newly_arrived_event_holder.cpp | 5 +- .../bcat/news/overwrite_event_holder.cpp | 4 +- .../filesystem/fsp/fs_i_filesystem.cpp | 4 +- .../fsp/fs_i_save_data_info_reader.cpp | 4 +- .../hle/service/glue/time/alarm_worker.cpp | 4 +- src/core/hle/service/glue/time/manager.cpp | 6 +- src/core/hle/service/glue/time/time_zone.cpp | 6 +- src/core/hle/service/glue/time/worker.cpp | 8 +- src/core/hle/service/hid/hid_debug_server.cpp | 4 +- src/core/hle/service/ipc_helpers.h | 4 +- src/core/hle/service/jit/jit_context.cpp | 4 +- src/core/hle/service/mii/mii.cpp | 4 +- src/core/hle/service/psc/time/alarms.cpp | 4 +- .../standard_user_system_clock_core.cpp | 4 +- src/core/hle/service/psc/time/common.cpp | 4 +- src/core/hle/service/psc/time/manager.h | 4 +- .../service/psc/time/power_state_service.cpp | 4 +- src/core/hle/service/psc/time/static.cpp | 4 +- .../hle/service/psc/time/steady_clock.cpp | 4 +- .../hle/service/psc/time/system_clock.cpp | 4 +- .../service/psc/time/time_zone_service.cpp | 4 +- src/core/hle/service/sm/sm.cpp | 4 +- .../vi/application_display_service.cpp | 4 +- src/core/memory/cheat_engine.cpp | 4 +- src/input_common/input_poller.cpp | 4 +- .../frontend/maxwell/control_flow.cpp | 4 +- .../maxwell/structured_control_flow.cpp | 4 +- src/suyu/applets/qt_web_browser.cpp | 4 +- src/suyu/bootmanager.cpp | 4 +- src/suyu/configuration/configure_dialog.cpp | 6 +- .../configuration/configure_input_player.cpp | 10 +- src/suyu/configuration/configure_per_game.cpp | 4 +- .../configure_per_game_addons.cpp | 169 +- .../configuration/configure_per_game_addons.h | 13 + .../configure_per_game_addons.ui | 76 +- src/suyu/configuration/shared_widget.cpp | 4 +- src/suyu/game_list_worker.cpp | 4 +- src/suyu/multiplayer/direct_connect.cpp | 4 +- src/suyu/multiplayer/host_room.cpp | 5 +- src/suyu/multiplayer/lobby.cpp | 5 +- src/video_core/cdma_pusher.cpp | 4 +- src/video_core/dma_pusher.cpp | 4 +- src/video_core/engines/maxwell_3d.cpp | 5 +- src/video_core/engines/puller.cpp | 4 +- src/video_core/host1x/codecs/decoder.cpp | 4 +- src/video_core/host1x/host1x.cpp | 4 +- src/video_core/host1x/vic.cpp | 4 +- src/video_core/memory_manager.cpp | 4 +- src/video_core/query_cache/query_cache.h | 4 +- .../renderer_opengl/gl_compute_pipeline.cpp | 4 +- .../renderer_opengl/gl_query_cache.cpp | 5 +- .../renderer_vulkan/present/fsr.cpp | 4 +- .../renderer_vulkan/vk_compute_pass.cpp | 4 +- .../renderer_vulkan/vk_compute_pipeline.cpp | 4 +- .../renderer_vulkan/vk_present_manager.cpp | 4 +- .../renderer_vulkan/vk_query_cache.cpp | 7 +- .../vk_staging_buffer_pool.cpp | 4 +- .../renderer_vulkan/vk_texture_cache.cpp | 2150 ++++++++--------- src/video_core/shader_environment.cpp | 4 +- src/video_core/vulkan_common/vulkan_wrapper.h | 12 +- 103 files changed, 1588 insertions(+), 1351 deletions(-) mode change 100755 => 100644 src/video_core/host1x/codecs/decoder.cpp diff --git a/.gitignore b/.gitignore index fbadb208be..2bb96e0e56 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ dist/english_plurals/generated_en.ts .idea/ .vs/ .vscode/ +.cache/ CMakeLists.txt.user* # *nix related diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b15c5baa1..874fcf6fa3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ stages: clang-format: stage: format image: suyuemu/cibuild:linux-x64 + allow_failure: true variables: RELEASE_NAME: mainline script: diff --git a/src/audio_core/in/audio_in.cpp b/src/audio_core/in/audio_in.cpp index df8c44d1f2..b28eb69786 100644 --- a/src/audio_core/in/audio_in.cpp +++ b/src/audio_core/in/audio_in.cpp @@ -8,8 +8,8 @@ namespace AudioCore::AudioIn { In::In(Core::System& system_, Manager& manager_, Kernel::KEvent* event_, size_t session_id_) - : manager{manager_}, parent_mutex{manager.mutex}, event{event_}, system{system_, event, - session_id_} {} + : manager{manager_}, parent_mutex{manager.mutex}, event{event_}, + system{system_, event, session_id_} {} void In::Free() { std::scoped_lock l{parent_mutex}; diff --git a/src/audio_core/in/audio_in_system.cpp b/src/audio_core/in/audio_in_system.cpp index b2dd3ef9f7..84d99877cb 100644 --- a/src/audio_core/in/audio_in_system.cpp +++ b/src/audio_core/in/audio_in_system.cpp @@ -14,8 +14,8 @@ namespace AudioCore::AudioIn { System::System(Core::System& system_, Kernel::KEvent* event_, const size_t session_id_) - : system{system_}, buffer_event{event_}, - session_id{session_id_}, session{std::make_unique(system_)} {} + : system{system_}, buffer_event{event_}, session_id{session_id_}, + session{std::make_unique(system_)} {} System::~System() { Finalize(); diff --git a/src/audio_core/out/audio_out.cpp b/src/audio_core/out/audio_out.cpp index b7ea134055..d31bced9df 100644 --- a/src/audio_core/out/audio_out.cpp +++ b/src/audio_core/out/audio_out.cpp @@ -8,8 +8,8 @@ namespace AudioCore::AudioOut { Out::Out(Core::System& system_, Manager& manager_, Kernel::KEvent* event_, size_t session_id_) - : manager{manager_}, parent_mutex{manager.mutex}, event{event_}, system{system_, event, - session_id_} {} + : manager{manager_}, parent_mutex{manager.mutex}, event{event_}, + system{system_, event, session_id_} {} void Out::Free() { std::scoped_lock l{parent_mutex}; diff --git a/src/audio_core/out/audio_out_system.cpp b/src/audio_core/out/audio_out_system.cpp index 7b3ff4e881..4c940be2d3 100644 --- a/src/audio_core/out/audio_out_system.cpp +++ b/src/audio_core/out/audio_out_system.cpp @@ -14,8 +14,8 @@ namespace AudioCore::AudioOut { System::System(Core::System& system_, Kernel::KEvent* event_, size_t session_id_) - : system{system_}, buffer_event{event_}, - session_id{session_id_}, session{std::make_unique(system_)} {} + : system{system_}, buffer_event{event_}, session_id{session_id_}, + session{std::make_unique(system_)} {} System::~System() { Finalize(); diff --git a/src/audio_core/renderer/behavior/info_updater.cpp b/src/audio_core/renderer/behavior/info_updater.cpp index 3dae6069f7..163127789c 100644 --- a/src/audio_core/renderer/behavior/info_updater.cpp +++ b/src/audio_core/renderer/behavior/info_updater.cpp @@ -19,10 +19,9 @@ namespace AudioCore::Renderer { InfoUpdater::InfoUpdater(std::span input_, std::span output_, Kernel::KProcess* process_handle_, BehaviorInfo& behaviour_) - : input{input_.data() + sizeof(UpdateDataHeader)}, - input_origin{input_}, output{output_.data() + sizeof(UpdateDataHeader)}, - output_origin{output_}, in_header{reinterpret_cast( - input_origin.data())}, + : input{input_.data() + sizeof(UpdateDataHeader)}, input_origin{input_}, + output{output_.data() + sizeof(UpdateDataHeader)}, output_origin{output_}, + in_header{reinterpret_cast(input_origin.data())}, out_header{reinterpret_cast(output_origin.data())}, expected_input_size{input_.size()}, expected_output_size{output_.size()}, process_handle{process_handle_}, behaviour{behaviour_} { diff --git a/src/audio_core/renderer/memory/pool_mapper.cpp b/src/audio_core/renderer/memory/pool_mapper.cpp index e47eb66d51..1df786feb5 100644 --- a/src/audio_core/renderer/memory/pool_mapper.cpp +++ b/src/audio_core/renderer/memory/pool_mapper.cpp @@ -13,8 +13,8 @@ PoolMapper::PoolMapper(Kernel::KProcess* process_handle_, bool force_map_) PoolMapper::PoolMapper(Kernel::KProcess* process_handle_, std::span pool_infos_, u32 pool_count_, bool force_map_) - : process_handle{process_handle_}, pool_infos{pool_infos_.data()}, - pool_count{pool_count_}, force_map{force_map_} {} + : process_handle{process_handle_}, pool_infos{pool_infos_.data()}, pool_count{pool_count_}, + force_map{force_map_} {} void PoolMapper::ClearUseState(std::span pools, const u32 count) { for (u32 i = 0; i < count; i++) { diff --git a/src/common/address_space.h b/src/common/address_space.h index 8683c23c39..694bb2aed3 100644 --- a/src/common/address_space.h +++ b/src/common/address_space.h @@ -12,8 +12,7 @@ namespace Common { template -concept AddressSpaceValid = std::is_unsigned_v && sizeof(VaType) * 8 >= -AddressSpaceBits; +concept AddressSpaceValid = std::is_unsigned_v && sizeof(VaType) * 8 >= AddressSpaceBits; struct EmptyStruct {}; diff --git a/src/common/concepts.h b/src/common/concepts.h index 61df1d32a2..a9acff3e79 100644 --- a/src/common/concepts.h +++ b/src/common/concepts.h @@ -16,9 +16,9 @@ concept IsContiguousContainer = std::contiguous_iterator; // is available on all supported platforms. template concept DerivedFrom = requires { - std::is_base_of_v; - std::is_convertible_v; - }; + std::is_base_of_v; + std::is_convertible_v; +}; // TODO: Replace with std::convertible_to when libc++ implements it. template diff --git a/src/common/expected.h b/src/common/expected.h index 5fccfbcbdd..c62e43164d 100644 --- a/src/common/expected.h +++ b/src/common/expected.h @@ -598,14 +598,14 @@ public: template >* = nullptr, std::enable_if_t>* = nullptr> constexpr explicit Expected(Unexpected&& e) noexcept(std::is_nothrow_constructible_v) - : impl_base{unexpect_t{}, std::move(e.value())}, ctor_base{ - detail::default_constructor_tag{}} {} + : impl_base{unexpect_t{}, std::move(e.value())}, + ctor_base{detail::default_constructor_tag{}} {} template >* = nullptr, std::enable_if_t>* = nullptr> constexpr Expected(Unexpected&& e) noexcept(std::is_nothrow_constructible_v) - : impl_base{unexpect_t{}, std::move(e.value())}, ctor_base{ - detail::default_constructor_tag{}} {} + : impl_base{unexpect_t{}, std::move(e.value())}, + ctor_base{detail::default_constructor_tag{}} {} template >* = nullptr> constexpr explicit Expected(unexpect_t, Args&&... args) diff --git a/src/common/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h index 6809acb47d..554194bb0b 100644 --- a/src/common/intrusive_red_black_tree.h +++ b/src/common/intrusive_red_black_tree.h @@ -238,10 +238,8 @@ public: template concept HasRedBlackKeyType = requires { - { - std::is_same::value - } -> std::convertible_to; - }; + { std::is_same::value } -> std::convertible_to; +}; namespace impl { diff --git a/src/common/multi_level_page_table.h b/src/common/multi_level_page_table.h index 31f6676a06..4eefb4d5f8 100644 --- a/src/common/multi_level_page_table.h +++ b/src/common/multi_level_page_table.h @@ -25,12 +25,12 @@ public: MultiLevelPageTable(MultiLevelPageTable&& other) noexcept : address_space_bits{std::exchange(other.address_space_bits, 0)}, - first_level_bits{std::exchange(other.first_level_bits, 0)}, page_bits{std::exchange( - other.page_bits, 0)}, + first_level_bits{std::exchange(other.first_level_bits, 0)}, + page_bits{std::exchange(other.page_bits, 0)}, first_level_shift{std::exchange(other.first_level_shift, 0)}, first_level_chunk_size{std::exchange(other.first_level_chunk_size, 0)}, - first_level_map{std::move(other.first_level_map)}, base_ptr{std::exchange(other.base_ptr, - nullptr)} {} + first_level_map{std::move(other.first_level_map)}, + base_ptr{std::exchange(other.base_ptr, nullptr)} {} MultiLevelPageTable& operator=(MultiLevelPageTable&& other) noexcept { address_space_bits = std::exchange(other.address_space_bits, 0); diff --git a/src/common/polyfill_ranges.h b/src/common/polyfill_ranges.h index 512dbcbcb7..ea542fe120 100644 --- a/src/common/polyfill_ranges.h +++ b/src/common/polyfill_ranges.h @@ -18,9 +18,9 @@ namespace ranges { template concept range = requires(T& t) { - begin(t); - end(t); - }; + begin(t); + end(t); +}; template concept input_range = range; diff --git a/src/common/tree.h b/src/common/tree.h index f4fc43de36..a260e83a32 100644 --- a/src/common/tree.h +++ b/src/common/tree.h @@ -103,9 +103,9 @@ concept IsRBEntry = CheckRBEntry::value; template concept HasRBEntry = requires(T& t, const T& ct) { - { t.GetRBEntry() } -> std::same_as&>; - { ct.GetRBEntry() } -> std::same_as&>; - }; + { t.GetRBEntry() } -> std::same_as&>; + { ct.GetRBEntry() } -> std::same_as&>; +}; template requires HasRBEntry diff --git a/src/common/vector_math.h b/src/common/vector_math.h index b4885835df..720e89f491 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -362,7 +362,9 @@ public: // _DEFINE_SWIZZLER2 defines a single such function, DEFINE_SWIZZLER2 defines all of them for all // component names (x<->r) and permutations (xy<->yx) #define _DEFINE_SWIZZLER2(a, b, name) \ - [[nodiscard]] constexpr Vec2 name() const { return Vec2(a, b); } + [[nodiscard]] constexpr Vec2 name() const { \ + return Vec2(a, b); \ + } #define DEFINE_SWIZZLER2(a, b, a2, b2, a3, b3, a4, b4) \ _DEFINE_SWIZZLER2(a, b, a##b); \ _DEFINE_SWIZZLER2(a, b, a2##b2); \ @@ -555,7 +557,9 @@ public: // DEFINE_SWIZZLER2_COMP2 defines two component functions for all component names (x<->r) and // permutations (xy<->yx) #define _DEFINE_SWIZZLER2(a, b, name) \ - [[nodiscard]] constexpr Vec2 name() const { return Vec2(a, b); } + [[nodiscard]] constexpr Vec2 name() const { \ + return Vec2(a, b); \ + } #define DEFINE_SWIZZLER2_COMP1(a, a2) \ _DEFINE_SWIZZLER2(a, a, a##a); \ _DEFINE_SWIZZLER2(a, a, a2##a2) @@ -580,7 +584,9 @@ public: #undef _DEFINE_SWIZZLER2 #define _DEFINE_SWIZZLER3(a, b, c, name) \ - [[nodiscard]] constexpr Vec3 name() const { return Vec3(a, b, c); } + [[nodiscard]] constexpr Vec3 name() const { \ + return Vec3(a, b, c); \ + } #define DEFINE_SWIZZLER3_COMP1(a, a2) \ _DEFINE_SWIZZLER3(a, a, a, a##a##a); \ _DEFINE_SWIZZLER3(a, a, a, a2##a2##a2) diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index 4f6e3e6e5c..a6cf25baa2 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -33,8 +33,8 @@ public: VirtualBuffer& operator=(const VirtualBuffer&) = delete; VirtualBuffer(VirtualBuffer&& other) noexcept - : alloc_size{std::exchange(other.alloc_size, 0)}, base_ptr{std::exchange(other.base_ptr), - nullptr} {} + : alloc_size{std::exchange(other.alloc_size, 0)}, + base_ptr{std::exchange(other.base_ptr), nullptr} {} VirtualBuffer& operator=(VirtualBuffer&& other) noexcept { alloc_size = std::exchange(other.alloc_size, 0); diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index d2d27fafea..80d6e2bc5c 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp @@ -8,8 +8,8 @@ namespace Common::X64 { NativeClock::NativeClock(u64 rdtsc_frequency_) - : rdtsc_frequency{rdtsc_frequency_}, ns_rdtsc_factor{GetFixedPoint64Factor(NsRatio::den, - rdtsc_frequency)}, + : rdtsc_frequency{rdtsc_frequency_}, + ns_rdtsc_factor{GetFixedPoint64Factor(NsRatio::den, rdtsc_frequency)}, us_rdtsc_factor{GetFixedPoint64Factor(UsRatio::den, rdtsc_frequency)}, ms_rdtsc_factor{GetFixedPoint64Factor(MsRatio::den, rdtsc_frequency)}, cntpct_rdtsc_factor{GetFixedPoint64Factor(CNTFRQ, rdtsc_frequency)}, diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 36478f7224..c9df0c022e 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -16,8 +16,8 @@ using namespace Common::Literals; class DynarmicCallbacks32 : public Dynarmic::A32::UserCallbacks { public: explicit DynarmicCallbacks32(ArmDynarmic32& parent, Kernel::KProcess* process) - : m_parent{parent}, m_memory(process->GetMemory()), - m_process(process), m_debugger_enabled{parent.m_system.DebuggerEnabled()}, + : m_parent{parent}, m_memory(process->GetMemory()), m_process(process), + m_debugger_enabled{parent.m_system.DebuggerEnabled()}, m_check_memory_access{m_debugger_enabled || !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index c811c8ad56..77a0b352f1 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -16,8 +16,8 @@ using namespace Common::Literals; class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks { public: explicit DynarmicCallbacks64(ArmDynarmic64& parent, Kernel::KProcess* process) - : m_parent{parent}, m_memory(process->GetMemory()), - m_process(process), m_debugger_enabled{parent.m_system.DebuggerEnabled()}, + : m_parent{parent}, m_memory(process->GetMemory()), m_process(process), + m_debugger_enabled{parent.m_system.DebuggerEnabled()}, m_check_memory_access{m_debugger_enabled || !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp index 0bcf40cf86..396a40d013 100644 --- a/src/core/file_sys/card_image.cpp +++ b/src/core/file_sys/card_image.cpp @@ -29,8 +29,8 @@ constexpr std::array partition_names{ XCI::XCI(VirtualFile file_, u64 program_id, size_t program_index) : file(std::move(file_)), program_nca_status{Loader::ResultStatus::ErrorXCIMissingProgramNCA}, - partitions(partition_names.size()), - partitions_raw(partition_names.size()), keys{Core::Crypto::KeyManager::Instance()} { + partitions(partition_names.size()), partitions_raw(partition_names.size()), + keys{Core::Crypto::KeyManager::Instance()} { const auto header_status = TryReadHeader(); if (header_status != Loader::ResultStatus::Success) { status = header_status; diff --git a/src/core/file_sys/fs_path_utility.h b/src/core/file_sys/fs_path_utility.h index cdfd8c7729..51418ee160 100644 --- a/src/core/file_sys/fs_path_utility.h +++ b/src/core/file_sys/fs_path_utility.h @@ -91,8 +91,12 @@ public: } #define DECLARE_PATH_FLAG_HANDLER(__WHICH__) \ - constexpr bool Is##__WHICH__##Allowed() const { return (m_value & __WHICH__##Flag) != 0; } \ - constexpr void Allow##__WHICH__() { m_value |= __WHICH__##Flag; } + constexpr bool Is##__WHICH__##Allowed() const { \ + return (m_value & __WHICH__##Flag) != 0; \ + } \ + constexpr void Allow##__WHICH__() { \ + m_value |= __WHICH__##Flag; \ + } DECLARE_PATH_FLAG_HANDLER(WindowsPath) DECLARE_PATH_FLAG_HANDLER(RelativePath) diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 21d45235e4..fe02800dc7 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -486,6 +486,8 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { .name = "Update", .version = "", .type = PatchType::Update, + .file_path = std::nullopt, + .root_path = std::nullopt, .program_id = title_id, .title_id = title_id}; @@ -514,6 +516,9 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { std::string types; const auto exefs_dir = FindSubdirectoryCaseless(mod, "exefs"); + std::optional file_path = std::nullopt; + std::optional root_path = std::nullopt; + if (IsDirValidAndNonEmpty(exefs_dir)) { bool ips = false; bool ipswitch = false; @@ -523,6 +528,8 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { if (file->GetExtension() == "ips") { ips = true; } else if (file->GetExtension() == "pchtxt") { + file_path = file->GetFullPath(); + root_path = exefs_dir->GetParentDirectory()->GetFullPath(); ipswitch = true; } else if (std::find(EXEFS_FILE_NAMES.begin(), EXEFS_FILE_NAMES.end(), file->GetName()) != EXEFS_FILE_NAMES.end()) { @@ -551,6 +558,8 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { .name = mod->GetName(), .version = types, .type = PatchType::Mod, + .file_path = file_path, + .root_path = root_path, .program_id = title_id, .title_id = title_id}); } @@ -574,6 +583,7 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { .name = "SDMC", .version = types, .type = PatchType::Mod, + .file_path = std::nullopt, .program_id = title_id, .title_id = title_id}); } @@ -606,6 +616,8 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { .name = "DLC", .version = std::move(list), .type = PatchType::DLC, + .file_path = std::nullopt, + .root_path = std::nullopt, .program_id = title_id, .title_id = dlc_match.back().title_id}); } diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index 552c0fbe23..6a58cf23a1 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h @@ -33,6 +33,8 @@ struct Patch { std::string name; std::string version; PatchType type; + std::optional file_path; + std::optional root_path; u64 program_id; u64 title_id; }; diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 68e8ec22fc..59173c6170 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp @@ -19,9 +19,9 @@ namespace FileSys { NSP::NSP(VirtualFile file_, u64 title_id_, std::size_t program_index_) - : file(std::move(file_)), expected_program_id(title_id_), - program_index(program_index_), status{Loader::ResultStatus::Success}, - pfs(std::make_shared(file)), keys{Core::Crypto::KeyManager::Instance()} { + : file(std::move(file_)), expected_program_id(title_id_), program_index(program_index_), + status{Loader::ResultStatus::Success}, pfs(std::make_shared(file)), + keys{Core::Crypto::KeyManager::Instance()} { if (pfs->GetStatus() != Loader::ResultStatus::Success) { status = pfs->GetStatus(); return; diff --git a/src/core/file_sys/xts_archive.cpp b/src/core/file_sys/xts_archive.cpp index 6692211e1d..64fa442826 100644 --- a/src/core/file_sys/xts_archive.cpp +++ b/src/core/file_sys/xts_archive.cpp @@ -44,8 +44,8 @@ static bool CalculateHMAC256(Destination* out, const SourceKey* key, std::size_t } NAX::NAX(VirtualFile file_) - : header(std::make_unique()), - file(std::move(file_)), keys{Core::Crypto::KeyManager::Instance()} { + : header(std::make_unique()), file(std::move(file_)), + keys{Core::Crypto::KeyManager::Instance()} { std::string path = Common::FS::SanitizePath(file->GetFullPath()); static const std::regex nax_path_regex("/registered/(000000[0-9A-F]{2})/([0-9A-F]{32})\\.nca", std::regex_constants::ECMAScript | @@ -62,8 +62,8 @@ NAX::NAX(VirtualFile file_) } NAX::NAX(VirtualFile file_, std::array nca_id) - : header(std::make_unique()), - file(std::move(file_)), keys{Core::Crypto::KeyManager::Instance()} { + : header(std::make_unique()), file(std::move(file_)), + keys{Core::Crypto::KeyManager::Instance()} { Core::Crypto::SHA256Hash hash{}; mbedtls_sha256_ret(nca_id.data(), nca_id.size(), hash.data(), 0); status = Parse(fmt::format("/registered/000000{:02X}/{}.nca", hash[0], diff --git a/src/core/hle/kernel/k_auto_object.h b/src/core/hle/kernel/k_auto_object.h index 3ec056119b..6e1a5246de 100644 --- a/src/core/hle/kernel/k_auto_object.h +++ b/src/core/hle/kernel/k_auto_object.h @@ -24,7 +24,9 @@ private: friend class ::Kernel::KClassTokenGenerator; \ static constexpr inline auto ObjectType = ::Kernel::KClassTokenGenerator::ObjectType::CLASS; \ static constexpr inline const char* const TypeName = #CLASS; \ - static constexpr inline ClassTokenType ClassToken() { return ::Kernel::ClassToken; } \ + static constexpr inline ClassTokenType ClassToken() { \ + return ::Kernel::ClassToken; \ + } \ \ public: \ SUYU_NON_COPYABLE(CLASS); \ @@ -35,9 +37,15 @@ public: constexpr ClassTokenType Token = ClassToken(); \ return TypeObj(TypeName, Token); \ } \ - static constexpr const char* GetStaticTypeName() { return TypeName; } \ - virtual TypeObj GetTypeObj() ATTRIBUTE { return GetStaticTypeObj(); } \ - virtual const char* GetTypeName() ATTRIBUTE { return GetStaticTypeName(); } \ + static constexpr const char* GetStaticTypeName() { \ + return TypeName; \ + } \ + virtual TypeObj GetTypeObj() ATTRIBUTE { \ + return GetStaticTypeObj(); \ + } \ + virtual const char* GetTypeName() ATTRIBUTE { \ + return GetStaticTypeName(); \ + } \ \ private: \ constexpr bool operator!=(const TypeObj& rhs) diff --git a/src/core/hle/kernel/k_memory_layout.cpp b/src/core/hle/kernel/k_memory_layout.cpp index bec7146688..8aec520010 100644 --- a/src/core/hle/kernel/k_memory_layout.cpp +++ b/src/core/hle/kernel/k_memory_layout.cpp @@ -128,8 +128,8 @@ KVirtualAddress KMemoryRegionTree::GetRandomAlignedRegion(size_t size, size_t al KMemoryLayout::KMemoryLayout() : m_virtual_tree{m_memory_region_allocator}, m_physical_tree{m_memory_region_allocator}, - m_virtual_linear_tree{m_memory_region_allocator}, m_physical_linear_tree{ - m_memory_region_allocator} {} + m_virtual_linear_tree{m_memory_region_allocator}, + m_physical_linear_tree{m_memory_region_allocator} {} void KMemoryLayout::InitializeLinearMemoryRegionTrees(KPhysicalAddress aligned_linear_phys_start, KVirtualAddress linear_virtual_start) { diff --git a/src/core/hle/kernel/k_priority_queue.h b/src/core/hle/kernel/k_priority_queue.h index 26677ec65c..b250700293 100644 --- a/src/core/hle/kernel/k_priority_queue.h +++ b/src/core/hle/kernel/k_priority_queue.h @@ -17,38 +17,32 @@ namespace Kernel { class KThread; template -concept KPriorityQueueAffinityMask = ! -std::is_reference_v&& requires(T& t) { - { t.GetAffinityMask() } -> Common::ConvertibleTo; - { t.SetAffinityMask(0) }; +concept KPriorityQueueAffinityMask = !std::is_reference_v && requires(T& t) { + { t.GetAffinityMask() } -> Common::ConvertibleTo; + { t.SetAffinityMask(0) }; - { t.GetAffinity(0) } -> std::same_as; - { t.SetAffinity(0, false) }; - { t.SetAll() }; - }; + { t.GetAffinity(0) } -> std::same_as; + { t.SetAffinity(0, false) }; + { t.SetAll() }; +}; template -concept KPriorityQueueMember = ! -std::is_reference_v&& requires(T& t) { - { typename T::QueueEntry() }; - { (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; +concept KPriorityQueueMember = !std::is_reference_v && requires(T& t) { + { typename T::QueueEntry() }; + { (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; - { t.GetAffinityMask() }; - { - std::remove_cvref_t() - } -> KPriorityQueueAffinityMask; + { t.GetAffinityMask() }; + { std::remove_cvref_t() } -> KPriorityQueueAffinityMask; - { t.GetActiveCore() } -> Common::ConvertibleTo; - { t.GetPriority() } -> Common::ConvertibleTo; - { t.IsDummyThread() } -> Common::ConvertibleTo; - }; + { t.GetActiveCore() } -> Common::ConvertibleTo; + { t.GetPriority() } -> Common::ConvertibleTo; + { t.IsDummyThread() } -> Common::ConvertibleTo; +}; template requires KPriorityQueueMember diff --git a/src/core/hle/kernel/k_scoped_lock.h b/src/core/hle/kernel/k_scoped_lock.h index 629a7d20dd..bc9830b4da 100644 --- a/src/core/hle/kernel/k_scoped_lock.h +++ b/src/core/hle/kernel/k_scoped_lock.h @@ -10,11 +10,10 @@ namespace Kernel { template -concept KLockable = ! -std::is_reference_v&& requires(T& t) { - { t.Lock() } -> std::same_as; - { t.Unlock() } -> std::same_as; - }; +concept KLockable = !std::is_reference_v && requires(T& t) { + { t.Lock() } -> std::same_as; + { t.Unlock() } -> std::same_as; +}; template requires KLockable diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 9a7c10efae..7016a5ecea 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -458,9 +458,13 @@ constexpr inline Result __TmpCurrentResultReference = ResultSuccess; if (true) #define R_CONVERT(catch_type, convert_type) \ - R_CATCH(catch_type) { R_THROW(static_cast(convert_type)); } + R_CATCH(catch_type) { \ + R_THROW(static_cast(convert_type)); \ + } #define R_CONVERT_ALL(convert_type) \ - R_CATCH_ALL() { R_THROW(static_cast(convert_type)); } + R_CATCH_ALL() { \ + R_THROW(static_cast(convert_type)); \ + } #define R_ASSERT(res_expr) ASSERT(R_SUCCEEDED(res_expr)) diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 099fdbc368..4f176e4f8a 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -1028,8 +1028,8 @@ void Module::Interface::TrySelectUserWithoutInteraction(HLERequestContext& ctx) Module::Interface::Interface(std::shared_ptr module_, std::shared_ptr profile_manager_, Core::System& system_, const char* name) - : ServiceFramework{system_, name}, module{std::move(module_)}, profile_manager{std::move( - profile_manager_)} {} + : ServiceFramework{system_, name}, module{std::move(module_)}, + profile_manager{std::move(profile_manager_)} {} Module::Interface::~Interface() = default; diff --git a/src/core/hle/service/am/frontend/applet_cabinet.cpp b/src/core/hle/service/am/frontend/applet_cabinet.cpp index 4cbc80d639..2fb9a83531 100644 --- a/src/core/hle/service/am/frontend/applet_cabinet.cpp +++ b/src/core/hle/service/am/frontend/applet_cabinet.cpp @@ -18,9 +18,8 @@ namespace Service::AM::Frontend { Cabinet::Cabinet(Core::System& system_, std::shared_ptr applet_, LibraryAppletMode applet_mode_, const Core::Frontend::CabinetApplet& frontend_) - : FrontendApplet{system_, applet_, applet_mode_}, frontend{frontend_}, service_context{ - system_, - "CabinetApplet"} { + : FrontendApplet{system_, applet_, applet_mode_}, frontend{frontend_}, + service_context{system_, "CabinetApplet"} { availability_change_event = service_context.CreateEvent("CabinetApplet:AvailabilityChangeEvent"); diff --git a/src/core/hle/service/am/service/application_proxy.cpp b/src/core/hle/service/am/service/application_proxy.cpp index 6e1328fee7..633f2c2bbd 100644 --- a/src/core/hle/service/am/service/application_proxy.cpp +++ b/src/core/hle/service/am/service/application_proxy.cpp @@ -18,8 +18,8 @@ namespace Service::AM { IApplicationProxy::IApplicationProxy(Core::System& system_, std::shared_ptr applet, Kernel::KProcess* process, WindowSystem& window_system) - : ServiceFramework{system_, "IApplicationProxy"}, - m_window_system{window_system}, m_process{process}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "IApplicationProxy"}, m_window_system{window_system}, + m_process{process}, m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IApplicationProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index 3ffb03bc97..d61aa42516 100644 --- a/src/core/hle/service/am/service/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp @@ -165,8 +165,8 @@ std::shared_ptr CreateFrontendApplet(Core::System& syste ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_, std::shared_ptr applet, WindowSystem& window_system) - : ServiceFramework{system_, "ILibraryAppletCreator"}, - m_window_system{window_system}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "ILibraryAppletCreator"}, m_window_system{window_system}, + m_applet{std::move(applet)} { static const FunctionInfo functions[] = { {0, D<&ILibraryAppletCreator::CreateLibraryApplet>, "CreateLibraryApplet"}, {1, nullptr, "TerminateAllLibraryApplets"}, diff --git a/src/core/hle/service/am/service/library_applet_proxy.cpp b/src/core/hle/service/am/service/library_applet_proxy.cpp index f9cfb82a90..655dd69b29 100644 --- a/src/core/hle/service/am/service/library_applet_proxy.cpp +++ b/src/core/hle/service/am/service/library_applet_proxy.cpp @@ -20,8 +20,8 @@ namespace Service::AM { ILibraryAppletProxy::ILibraryAppletProxy(Core::System& system_, std::shared_ptr applet, Kernel::KProcess* process, WindowSystem& window_system) - : ServiceFramework{system_, "ILibraryAppletProxy"}, - m_window_system{window_system}, m_process{process}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "ILibraryAppletProxy"}, m_window_system{window_system}, + m_process{process}, m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&ILibraryAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, diff --git a/src/core/hle/service/am/service/self_controller.cpp b/src/core/hle/service/am/service/self_controller.cpp index e2b17099a3..52efda973d 100644 --- a/src/core/hle/service/am/service/self_controller.cpp +++ b/src/core/hle/service/am/service/self_controller.cpp @@ -16,8 +16,8 @@ namespace Service::AM { ISelfController::ISelfController(Core::System& system_, std::shared_ptr applet, Kernel::KProcess* process) - : ServiceFramework{system_, "ISelfController"}, m_process{process}, m_applet{ - std::move(applet)} { + : ServiceFramework{system_, "ISelfController"}, m_process{process}, + m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&ISelfController::Exit>, "Exit"}, diff --git a/src/core/hle/service/am/service/system_applet_proxy.cpp b/src/core/hle/service/am/service/system_applet_proxy.cpp index c435288a26..609c4aad3e 100644 --- a/src/core/hle/service/am/service/system_applet_proxy.cpp +++ b/src/core/hle/service/am/service/system_applet_proxy.cpp @@ -20,8 +20,8 @@ namespace Service::AM { ISystemAppletProxy::ISystemAppletProxy(Core::System& system_, std::shared_ptr applet, Kernel::KProcess* process, WindowSystem& window_system) - : ServiceFramework{system_, "ISystemAppletProxy"}, - m_window_system{window_system}, m_process{process}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "ISystemAppletProxy"}, m_window_system{window_system}, + m_process{process}, m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&ISystemAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, diff --git a/src/core/hle/service/am/service/window_controller.cpp b/src/core/hle/service/am/service/window_controller.cpp index 54396affbe..6b1759f037 100644 --- a/src/core/hle/service/am/service/window_controller.cpp +++ b/src/core/hle/service/am/service/window_controller.cpp @@ -11,8 +11,8 @@ namespace Service::AM { IWindowController::IWindowController(Core::System& system_, std::shared_ptr applet, WindowSystem& window_system) - : ServiceFramework{system_, "IWindowController"}, - m_window_system{window_system}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "IWindowController"}, m_window_system{window_system}, + m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "CreateWindow"}, diff --git a/src/core/hle/service/aoc/purchase_event_manager.cpp b/src/core/hle/service/aoc/purchase_event_manager.cpp index 9e718510b4..1192263f8a 100644 --- a/src/core/hle/service/aoc/purchase_event_manager.cpp +++ b/src/core/hle/service/aoc/purchase_event_manager.cpp @@ -9,8 +9,8 @@ namespace Service::AOC { constexpr Result ResultNoPurchasedProductInfoAvailable{ErrorModule::NIMShop, 400}; IPurchaseEventManager::IPurchaseEventManager(Core::System& system_) - : ServiceFramework{system_, "IPurchaseEventManager"}, service_context{system, - "IPurchaseEventManager"} { + : ServiceFramework{system_, "IPurchaseEventManager"}, + service_context{system, "IPurchaseEventManager"} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IPurchaseEventManager::SetDefaultDeliveryTarget>, "SetDefaultDeliveryTarget"}, diff --git a/src/core/hle/service/audio/audio_in.cpp b/src/core/hle/service/audio/audio_in.cpp index 416803acc3..9240cc3363 100644 --- a/src/core/hle/service/audio/audio_in.cpp +++ b/src/core/hle/service/audio/audio_in.cpp @@ -12,9 +12,8 @@ IAudioIn::IAudioIn(Core::System& system_, Manager& manager, size_t session_id, const std::string& device_name, const AudioInParameter& in_params, Kernel::KProcess* handle, u64 applet_resource_user_id) : ServiceFramework{system_, "IAudioIn"}, process{handle}, service_context{system_, "IAudioIn"}, - event{service_context.CreateEvent("AudioInEvent")}, impl{std::make_shared(system_, - manager, event, - session_id)} { + event{service_context.CreateEvent("AudioInEvent")}, + impl{std::make_shared(system_, manager, event, session_id)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioIn::GetAudioInState>, "GetAudioInState"}, diff --git a/src/core/hle/service/audio/audio_in_manager.cpp b/src/core/hle/service/audio/audio_in_manager.cpp index 2675a57735..d55da17c84 100644 --- a/src/core/hle/service/audio/audio_in_manager.cpp +++ b/src/core/hle/service/audio/audio_in_manager.cpp @@ -10,8 +10,8 @@ namespace Service::Audio { using namespace AudioCore::AudioIn; IAudioInManager::IAudioInManager(Core::System& system_) - : ServiceFramework{system_, "audin:u"}, impl{std::make_unique( - system_)} { + : ServiceFramework{system_, "audin:u"}, + impl{std::make_unique(system_)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioInManager::ListAudioIns>, "ListAudioIns"}, diff --git a/src/core/hle/service/audio/audio_renderer.cpp b/src/core/hle/service/audio/audio_renderer.cpp index fc4aad2339..b78660cea6 100644 --- a/src/core/hle/service/audio/audio_renderer.cpp +++ b/src/core/hle/service/audio/audio_renderer.cpp @@ -14,8 +14,8 @@ IAudioRenderer::IAudioRenderer(Core::System& system_, Manager& manager_, s32 session_id) : ServiceFramework{system_, "IAudioRenderer"}, service_context{system_, "IAudioRenderer"}, rendered_event{service_context.CreateEvent("IAudioRendererEvent")}, manager{manager_}, - impl{std::make_unique(system_, manager, rendered_event)}, process_handle{ - process_handle_} { + impl{std::make_unique(system_, manager, rendered_event)}, + process_handle{process_handle_} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioRenderer::GetSampleRate>, "GetSampleRate"}, diff --git a/src/core/hle/service/bcat/news/newly_arrived_event_holder.cpp b/src/core/hle/service/bcat/news/newly_arrived_event_holder.cpp index ed393f7a26..8d64bd697a 100644 --- a/src/core/hle/service/bcat/news/newly_arrived_event_holder.cpp +++ b/src/core/hle/service/bcat/news/newly_arrived_event_holder.cpp @@ -7,9 +7,8 @@ namespace Service::News { INewlyArrivedEventHolder::INewlyArrivedEventHolder(Core::System& system_) - : ServiceFramework{system_, "INewlyArrivedEventHolder"}, service_context{ - system_, - "INewlyArrivedEventHolder"} { + : ServiceFramework{system_, "INewlyArrivedEventHolder"}, + service_context{system_, "INewlyArrivedEventHolder"} { // clang-format off static const FunctionInfo functions[] = { {0, D<&INewlyArrivedEventHolder::Get>, "Get"}, diff --git a/src/core/hle/service/bcat/news/overwrite_event_holder.cpp b/src/core/hle/service/bcat/news/overwrite_event_holder.cpp index 1712971e4d..33ea7c8951 100644 --- a/src/core/hle/service/bcat/news/overwrite_event_holder.cpp +++ b/src/core/hle/service/bcat/news/overwrite_event_holder.cpp @@ -7,8 +7,8 @@ namespace Service::News { IOverwriteEventHolder::IOverwriteEventHolder(Core::System& system_) - : ServiceFramework{system_, "IOverwriteEventHolder"}, service_context{system_, - "IOverwriteEventHolder"} { + : ServiceFramework{system_, "IOverwriteEventHolder"}, + service_context{system_, "IOverwriteEventHolder"} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IOverwriteEventHolder::Get>, "Get"}, diff --git a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp index d881e144d3..de7b550544 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp @@ -11,8 +11,8 @@ namespace Service::FileSystem { IFileSystem::IFileSystem(Core::System& system_, FileSys::VirtualDir dir_, SizeGetter size_getter_) - : ServiceFramework{system_, "IFileSystem"}, backend{std::make_unique( - dir_)}, + : ServiceFramework{system_, "IFileSystem"}, + backend{std::make_unique(dir_)}, size_getter{std::move(size_getter_)} { static const FunctionInfo functions[] = { {0, D<&IFileSystem::CreateFile>, "CreateFile"}, diff --git a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp index ff823586b3..9a603e89a2 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp @@ -12,8 +12,8 @@ namespace Service::FileSystem { ISaveDataInfoReader::ISaveDataInfoReader(Core::System& system_, std::shared_ptr save_data_controller_, FileSys::SaveDataSpaceId space) - : ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{ - save_data_controller_} { + : ServiceFramework{system_, "ISaveDataInfoReader"}, + save_data_controller{save_data_controller_} { static const FunctionInfo functions[] = { {0, D<&ISaveDataInfoReader::ReadSaveDataInfo>, "ReadSaveDataInfo"}, }; diff --git a/src/core/hle/service/glue/time/alarm_worker.cpp b/src/core/hle/service/glue/time/alarm_worker.cpp index 3ff071f4a0..21ace76936 100644 --- a/src/core/hle/service/glue/time/alarm_worker.cpp +++ b/src/core/hle/service/glue/time/alarm_worker.cpp @@ -11,8 +11,8 @@ namespace Service::Glue::Time { AlarmWorker::AlarmWorker(Core::System& system, StandardSteadyClockResource& steady_clock_resource) - : m_system{system}, m_ctx{system, "Glue:AlarmWorker"}, m_steady_clock_resource{ - steady_clock_resource} {} + : m_system{system}, m_ctx{system, "Glue:AlarmWorker"}, + m_steady_clock_resource{steady_clock_resource} {} AlarmWorker::~AlarmWorker() { m_system.CoreTiming().UnscheduleEvent(m_timer_timing_event); diff --git a/src/core/hle/service/glue/time/manager.cpp b/src/core/hle/service/glue/time/manager.cpp index 77bf8896cd..c1faf8eaab 100644 --- a/src/core/hle/service/glue/time/manager.cpp +++ b/src/core/hle/service/glue/time/manager.cpp @@ -87,10 +87,8 @@ static Service::PSC::Time::LocationName GetTimeZoneString( } TimeManager::TimeManager(Core::System& system) - : m_steady_clock_resource{system}, m_time_zone_binary{system}, m_worker{ - system, - m_steady_clock_resource, - m_file_timestamp_worker} { + : m_steady_clock_resource{system}, m_time_zone_binary{system}, + m_worker{system, m_steady_clock_resource, m_file_timestamp_worker} { m_time_m = system.ServiceManager().GetService("time:m", true); diff --git a/src/core/hle/service/glue/time/time_zone.cpp b/src/core/hle/service/glue/time/time_zone.cpp index b2e8159653..a89df753a4 100644 --- a/src/core/hle/service/glue/time/time_zone.cpp +++ b/src/core/hle/service/glue/time/time_zone.cpp @@ -22,9 +22,9 @@ TimeZoneService::TimeZoneService( std::shared_ptr time_zone_service) : ServiceFramework{system_, "ITimeZoneService"}, m_system{system}, m_can_write_timezone_device_location{can_write_timezone_device_location}, - m_file_timestamp_worker{file_timestamp_worker}, m_wrapped_service{std::move( - time_zone_service)}, - m_operation_event{m_system}, m_time_zone_binary{time_zone_binary} { + m_file_timestamp_worker{file_timestamp_worker}, + m_wrapped_service{std::move(time_zone_service)}, m_operation_event{m_system}, + m_time_zone_binary{time_zone_binary} { // clang-format off static const FunctionInfo functions[] = { {0, D<&TimeZoneService::GetDeviceLocationName>, "GetDeviceLocationName"}, diff --git a/src/core/hle/service/glue/time/worker.cpp b/src/core/hle/service/glue/time/worker.cpp index 1dab3e9dcb..90cfe0a973 100644 --- a/src/core/hle/service/glue/time/worker.cpp +++ b/src/core/hle/service/glue/time/worker.cpp @@ -19,11 +19,11 @@ namespace Service::Glue::Time { TimeWorker::TimeWorker(Core::System& system, StandardSteadyClockResource& steady_clock_resource, FileTimestampWorker& file_timestamp_worker) - : m_system{system}, m_ctx{m_system, "Glue:TimeWorker"}, m_event{m_ctx.CreateEvent( - "Glue:TimeWorker:Event")}, + : m_system{system}, m_ctx{m_system, "Glue:TimeWorker"}, + m_event{m_ctx.CreateEvent("Glue:TimeWorker:Event")}, m_steady_clock_resource{steady_clock_resource}, - m_file_timestamp_worker{file_timestamp_worker}, m_timer_steady_clock{m_ctx.CreateEvent( - "Glue:TimeWorker:SteadyClockTimerEvent")}, + m_file_timestamp_worker{file_timestamp_worker}, + m_timer_steady_clock{m_ctx.CreateEvent("Glue:TimeWorker:SteadyClockTimerEvent")}, m_timer_file_system{m_ctx.CreateEvent("Glue:TimeWorker:FileTimeTimerEvent")}, m_alarm_worker{m_system, m_steady_clock_resource}, m_pm_state_change_handler{m_alarm_worker} { m_timer_steady_clock_timing_event = Core::Timing::CreateEvent( diff --git a/src/core/hle/service/hid/hid_debug_server.cpp b/src/core/hle/service/hid/hid_debug_server.cpp index 4e26636725..debc9b4910 100644 --- a/src/core/hle/service/hid/hid_debug_server.cpp +++ b/src/core/hle/service/hid/hid_debug_server.cpp @@ -17,8 +17,8 @@ namespace Service::HID { IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr resource, std::shared_ptr settings) - : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource}, firmware_settings{ - settings} { + : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource}, + firmware_settings{settings} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "DeactivateDebugPad"}, diff --git a/src/core/hle/service/ipc_helpers.h b/src/core/hle/service/ipc_helpers.h index 4b02872fba..97b46d5889 100644 --- a/src/core/hle/service/ipc_helpers.h +++ b/src/core/hle/service/ipc_helpers.h @@ -72,8 +72,8 @@ public: u32 num_handles_to_copy_ = 0, u32 num_objects_to_move_ = 0, Flags flags = Flags::None) : RequestHelperBase(ctx), normal_params_size(normal_params_size_), - num_handles_to_copy(num_handles_to_copy_), - num_objects_to_move(num_objects_to_move_), kernel{ctx.kernel} { + num_handles_to_copy(num_handles_to_copy_), num_objects_to_move(num_objects_to_move_), + kernel{ctx.kernel} { memset(cmdbuf, 0, sizeof(u32) * IPC::COMMAND_BUFFER_LENGTH); diff --git a/src/core/hle/service/jit/jit_context.cpp b/src/core/hle/service/jit/jit_context.cpp index 0090e8568d..8df63f9e26 100644 --- a/src/core/hle/service/jit/jit_context.cpp +++ b/src/core/hle/service/jit/jit_context.cpp @@ -40,8 +40,8 @@ class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks { public: explicit DynarmicCallbacks64(Core::Memory::Memory& memory_, std::vector& local_memory_, IntervalSet& mapped_ranges_, JITContextImpl& parent_) - : memory{memory_}, local_memory{local_memory_}, - mapped_ranges{mapped_ranges_}, parent{parent_} {} + : memory{memory_}, local_memory{local_memory_}, mapped_ranges{mapped_ranges_}, + parent{parent_} {} u8 MemoryRead8(u64 vaddr) override { return ReadMemory(vaddr); diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index adaaea571a..5232bcd050 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -23,8 +23,8 @@ class IDatabaseService final : public ServiceFramework { public: explicit IDatabaseService(Core::System& system_, std::shared_ptr mii_manager, bool is_system_) - : ServiceFramework{system_, "IDatabaseService"}, manager{mii_manager}, is_system{ - is_system_} { + : ServiceFramework{system_, "IDatabaseService"}, manager{mii_manager}, + is_system{is_system_} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IDatabaseService::IsUpdated>, "IsUpdated"}, diff --git a/src/core/hle/service/psc/time/alarms.cpp b/src/core/hle/service/psc/time/alarms.cpp index 5e52c19f82..64af6db573 100644 --- a/src/core/hle/service/psc/time/alarms.cpp +++ b/src/core/hle/service/psc/time/alarms.cpp @@ -30,8 +30,8 @@ Alarm::~Alarm() { Alarms::Alarms(Core::System& system, StandardSteadyClockCore& steady_clock, PowerStateRequestManager& power_state_request_manager) : m_system{system}, m_ctx{system, "Psc:Alarms"}, m_steady_clock{steady_clock}, - m_power_state_request_manager{power_state_request_manager}, m_event{m_ctx.CreateEvent( - "Psc:Alarms:Event")} {} + m_power_state_request_manager{power_state_request_manager}, + m_event{m_ctx.CreateEvent("Psc:Alarms:Event")} {} Alarms::~Alarms() { m_ctx.CloseEvent(m_event); diff --git a/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp b/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp index 31ed273966..aa5b4c33c2 100644 --- a/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp @@ -11,8 +11,8 @@ StandardUserSystemClockCore::StandardUserSystemClockCore( StandardNetworkSystemClockCore& network_clock) : SystemClockCore{local_clock.GetSteadyClock()}, m_system{system}, m_ctx{m_system, "Psc:StandardUserSystemClockCore"}, m_local_system_clock{local_clock}, - m_network_system_clock{network_clock}, m_event{m_ctx.CreateEvent( - "Psc:StandardUserSystemClockCore:Event")} {} + m_network_system_clock{network_clock}, + m_event{m_ctx.CreateEvent("Psc:StandardUserSystemClockCore:Event")} {} StandardUserSystemClockCore::~StandardUserSystemClockCore() { m_ctx.CloseEvent(m_event); diff --git a/src/core/hle/service/psc/time/common.cpp b/src/core/hle/service/psc/time/common.cpp index a6d9f02ca3..1728c84499 100644 --- a/src/core/hle/service/psc/time/common.cpp +++ b/src/core/hle/service/psc/time/common.cpp @@ -6,8 +6,8 @@ namespace Service::PSC::Time { OperationEvent::OperationEvent(Core::System& system) - : m_ctx{system, "Time:OperationEvent"}, m_event{ - m_ctx.CreateEvent("Time:OperationEvent:Event")} {} + : m_ctx{system, "Time:OperationEvent"}, + m_event{m_ctx.CreateEvent("Time:OperationEvent:Event")} {} OperationEvent::~OperationEvent() { m_ctx.CloseEvent(m_event); diff --git a/src/core/hle/service/psc/time/manager.h b/src/core/hle/service/psc/time/manager.h index 62ded12475..57c682c690 100644 --- a/src/core/hle/service/psc/time/manager.h +++ b/src/core/hle/service/psc/time/manager.h @@ -29,8 +29,8 @@ public: m_standard_user_system_clock{m_system, m_standard_local_system_clock, m_standard_network_system_clock}, m_ephemeral_network_clock{m_tick_based_steady_clock}, m_shared_memory{m_system}, - m_power_state_request_manager{m_system}, m_alarms{m_system, m_standard_steady_clock, - m_power_state_request_manager}, + m_power_state_request_manager{m_system}, + m_alarms{m_system, m_standard_steady_clock, m_power_state_request_manager}, m_local_system_clock_context_writer{m_system, m_shared_memory}, m_network_system_clock_context_writer{m_system, m_shared_memory, m_standard_user_system_clock}, diff --git a/src/core/hle/service/psc/time/power_state_service.cpp b/src/core/hle/service/psc/time/power_state_service.cpp index ab1d32c703..6fe03dc2e8 100644 --- a/src/core/hle/service/psc/time/power_state_service.cpp +++ b/src/core/hle/service/psc/time/power_state_service.cpp @@ -8,8 +8,8 @@ namespace Service::PSC::Time { IPowerStateRequestHandler::IPowerStateRequestHandler( Core::System& system_, PowerStateRequestManager& power_state_request_manager) - : ServiceFramework{system_, "time:p"}, m_system{system}, m_power_state_request_manager{ - power_state_request_manager} { + : ServiceFramework{system_, "time:p"}, m_system{system}, + m_power_state_request_manager{power_state_request_manager} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IPowerStateRequestHandler::GetPowerStateRequestEventReadableHandle>, "GetPowerStateRequestEventReadableHandle"}, diff --git a/src/core/hle/service/psc/time/static.cpp b/src/core/hle/service/psc/time/static.cpp index 9a0adb2955..591849813e 100644 --- a/src/core/hle/service/psc/time/static.cpp +++ b/src/core/hle/service/psc/time/static.cpp @@ -37,8 +37,8 @@ StaticService::StaticService(Core::System& system_, StaticServiceSetupInfo setup m_user_system_clock{m_time->m_standard_user_system_clock}, m_network_system_clock{m_time->m_standard_network_system_clock}, m_time_zone{m_time->m_time_zone}, - m_ephemeral_network_clock{m_time->m_ephemeral_network_clock}, m_shared_memory{ - m_time->m_shared_memory} { + m_ephemeral_network_clock{m_time->m_ephemeral_network_clock}, + m_shared_memory{m_time->m_shared_memory} { // clang-format off static const FunctionInfo functions[] = { {0, D<&StaticService::GetStandardUserSystemClock>, "GetStandardUserSystemClock"}, diff --git a/src/core/hle/service/psc/time/steady_clock.cpp b/src/core/hle/service/psc/time/steady_clock.cpp index 78dcf532ce..cb10024f2f 100644 --- a/src/core/hle/service/psc/time/steady_clock.cpp +++ b/src/core/hle/service/psc/time/steady_clock.cpp @@ -12,8 +12,8 @@ SteadyClock::SteadyClock(Core::System& system_, std::shared_ptr man bool can_write_steady_clock, bool can_write_uninitialized_clock) : ServiceFramework{system_, "ISteadyClock"}, m_system{system}, m_clock_core{manager->m_standard_steady_clock}, - m_can_write_steady_clock{can_write_steady_clock}, m_can_write_uninitialized_clock{ - can_write_uninitialized_clock} { + m_can_write_steady_clock{can_write_steady_clock}, + m_can_write_uninitialized_clock{can_write_uninitialized_clock} { // clang-format off static const FunctionInfo functions[] = { {0, D<&SteadyClock::GetCurrentTimePoint>, "GetCurrentTimePoint"}, diff --git a/src/core/hle/service/psc/time/system_clock.cpp b/src/core/hle/service/psc/time/system_clock.cpp index 9f841d8e04..ed9f098045 100644 --- a/src/core/hle/service/psc/time/system_clock.cpp +++ b/src/core/hle/service/psc/time/system_clock.cpp @@ -11,8 +11,8 @@ namespace Service::PSC::Time { SystemClock::SystemClock(Core::System& system_, SystemClockCore& clock_core, bool can_write_clock, bool can_write_uninitialized_clock) : ServiceFramework{system_, "ISystemClock"}, m_system{system}, m_clock_core{clock_core}, - m_can_write_clock{can_write_clock}, m_can_write_uninitialized_clock{ - can_write_uninitialized_clock} { + m_can_write_clock{can_write_clock}, + m_can_write_uninitialized_clock{can_write_uninitialized_clock} { // clang-format off static const FunctionInfo functions[] = { {0, D<&SystemClock::GetCurrentTime>, "GetCurrentTime"}, diff --git a/src/core/hle/service/psc/time/time_zone_service.cpp b/src/core/hle/service/psc/time/time_zone_service.cpp index 9e0674f275..92e695a326 100644 --- a/src/core/hle/service/psc/time/time_zone_service.cpp +++ b/src/core/hle/service/psc/time/time_zone_service.cpp @@ -13,8 +13,8 @@ namespace Service::PSC::Time { TimeZoneService::TimeZoneService(Core::System& system_, StandardSteadyClockCore& clock_core, TimeZone& time_zone, bool can_write_timezone_device_location) : ServiceFramework{system_, "ITimeZoneService"}, m_system{system}, m_clock_core{clock_core}, - m_time_zone{time_zone}, m_can_write_timezone_device_location{ - can_write_timezone_device_location} { + m_time_zone{time_zone}, + m_can_write_timezone_device_location{can_write_timezone_device_location} { // clang-format off static const FunctionInfo functions[] = { {0, D<&TimeZoneService::GetDeviceLocationName>, "GetDeviceLocationName"}, diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 1095dcf6c3..1373da17fa 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -251,8 +251,8 @@ void SM::UnregisterService(HLERequestContext& ctx) { } SM::SM(ServiceManager& service_manager_, Core::System& system_) - : ServiceFramework{system_, "sm:", 4}, - service_manager{service_manager_}, kernel{system_.Kernel()} { + : ServiceFramework{system_, "sm:", 4}, service_manager{service_manager_}, + kernel{system_.Kernel()} { RegisterHandlers({ {0, &SM::Initialize, "Initialize"}, {1, &SM::GetServiceCmif, "GetService"}, diff --git a/src/core/hle/service/vi/application_display_service.cpp b/src/core/hle/service/vi/application_display_service.cpp index 6b0bcb5362..2cc38c24d3 100644 --- a/src/core/hle/service/vi/application_display_service.cpp +++ b/src/core/hle/service/vi/application_display_service.cpp @@ -15,8 +15,8 @@ namespace Service::VI { IApplicationDisplayService::IApplicationDisplayService(Core::System& system_, std::shared_ptr container) - : ServiceFramework{system_, "IApplicationDisplayService"}, - m_container{std::move(container)}, m_context{system, "IApplicationDisplayService"} { + : ServiceFramework{system_, "IApplicationDisplayService"}, m_container{std::move(container)}, + m_context{system, "IApplicationDisplayService"} { // clang-format off static const FunctionInfo functions[] = { {100, C<&IApplicationDisplayService::GetRelayService>, "GetRelayService"}, diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp index d8921e5658..ae651631d6 100644 --- a/src/core/memory/cheat_engine.cpp +++ b/src/core/memory/cheat_engine.cpp @@ -218,8 +218,8 @@ std::vector TextCheatParser::Parse(std::string_view data) const { CheatEngine::CheatEngine(System& system_, std::vector cheats_, const std::array& build_id_) - : vm{std::make_unique(system_, metadata)}, - cheats(std::move(cheats_)), core_timing{system_.CoreTiming()}, system{system_} { + : vm{std::make_unique(system_, metadata)}, cheats(std::move(cheats_)), + core_timing{system_.CoreTiming()}, system{system_} { metadata.main_nso_build_id = build_id_; } diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 0cc0fecb34..f7e6986938 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp @@ -148,8 +148,8 @@ public: Common::Input::AnalogProperties properties_y_, InputEngine* input_engine_) : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), - properties_y(properties_y_), - input_engine(input_engine_), invert_axis_y{input_engine_->GetEngineName() == "sdl"} { + properties_y(properties_y_), input_engine(input_engine_), + invert_axis_y{input_engine_->GetEngineName() == "sdl"} { UpdateCallback engine_callback{[this]() { OnChange(); }}; const InputIdentifier x_input_identifier{ .identifier = identifier, diff --git a/src/shader_recompiler/frontend/maxwell/control_flow.cpp b/src/shader_recompiler/frontend/maxwell/control_flow.cpp index dce414cb47..e0d6315754 100644 --- a/src/shader_recompiler/frontend/maxwell/control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/control_flow.cpp @@ -186,8 +186,8 @@ Function::Function(ObjectPool& block_pool, Location start_address) CFG::CFG(Environment& env_, ObjectPool& block_pool_, Location start_address, bool exits_to_dispatcher_) - : env{env_}, block_pool{block_pool_}, program_start{start_address}, exits_to_dispatcher{ - exits_to_dispatcher_} { + : env{env_}, block_pool{block_pool_}, program_start{start_address}, + exits_to_dispatcher{exits_to_dispatcher_} { if (exits_to_dispatcher) { dispatch_block = block_pool.Create(Block{}); dispatch_block->begin = {}; diff --git a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp index 80c90fe6ac..93538fa4cf 100644 --- a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp @@ -112,8 +112,8 @@ struct Statement : ListBaseHook { Statement(SetVariable, u32 id_, Statement* op_, Statement* up_) : op{op_}, id{id_}, up{up_}, type{StatementType::SetVariable} {} Statement(SetIndirectBranchVariable, IR::Reg branch_reg_, s32 branch_offset_, Statement* up_) - : branch_offset{branch_offset_}, - branch_reg{branch_reg_}, up{up_}, type{StatementType::SetIndirectBranchVariable} {} + : branch_offset{branch_offset_}, branch_reg{branch_reg_}, up{up_}, + type{StatementType::SetIndirectBranchVariable} {} Statement(Variable, u32 id_, Statement* up_) : id{id_}, up{up_}, type{StatementType::Variable} {} Statement(IndirectBranchCond, u32 location_, Statement* up_) diff --git a/src/suyu/applets/qt_web_browser.cpp b/src/suyu/applets/qt_web_browser.cpp index a7d7a5ce65..7c06bb6104 100644 --- a/src/suyu/applets/qt_web_browser.cpp +++ b/src/suyu/applets/qt_web_browser.cpp @@ -54,8 +54,8 @@ QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system, : QWebEngineView(parent), input_subsystem{input_subsystem_}, url_interceptor(std::make_unique()), input_interpreter(std::make_unique(system)), - default_profile{QWebEngineProfile::defaultProfile()}, global_settings{ - default_profile->settings()} { + default_profile{QWebEngineProfile::defaultProfile()}, + global_settings{default_profile->settings()} { default_profile->setPersistentStoragePath(QString::fromStdString(Common::FS::PathToUTF8String( Common::FS::GetSuyuPath(Common::FS::SuyuPath::SuyuDir) / "qtwebengine"))); diff --git a/src/suyu/bootmanager.cpp b/src/suyu/bootmanager.cpp index 3c536e3072..470455692b 100644 --- a/src/suyu/bootmanager.cpp +++ b/src/suyu/bootmanager.cpp @@ -284,8 +284,8 @@ struct NullRenderWidget : public RenderWidget { GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, std::shared_ptr input_subsystem_, Core::System& system_) - : QWidget(parent), - emu_thread(emu_thread_), input_subsystem{std::move(input_subsystem_)}, system{system_} { + : QWidget(parent), emu_thread(emu_thread_), input_subsystem{std::move(input_subsystem_)}, + system{system_} { setWindowTitle(QStringLiteral("suyu %1 | %2-%3") .arg(QString::fromUtf8(Common::g_build_name), QString::fromUtf8(Common::g_scm_branch), diff --git a/src/suyu/configuration/configure_dialog.cpp b/src/suyu/configuration/configure_dialog.cpp index 0d6ac9ad82..d81edaa3b2 100644 --- a/src/suyu/configuration/configure_dialog.cpp +++ b/src/suyu/configuration/configure_dialog.cpp @@ -32,9 +32,9 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, InputCommon::InputSubsystem* input_subsystem, std::vector& vk_device_records, Core::System& system_, bool enable_web_config) - : QDialog(parent), ui{std::make_unique()}, - registry(registry_), system{system_}, builder{std::make_unique( - this, !system_.IsPoweredOn())}, + : QDialog(parent), ui{std::make_unique()}, registry(registry_), + system{system_}, + builder{std::make_unique(this, !system_.IsPoweredOn())}, applets_tab{std::make_unique(system_, nullptr, *builder, this)}, audio_tab{std::make_unique(system_, nullptr, *builder, this)}, cpu_tab{std::make_unique(system_, nullptr, *builder, this)}, diff --git a/src/suyu/configuration/configure_input_player.cpp b/src/suyu/configuration/configure_input_player.cpp index 1fd176e987..ec0c09790e 100644 --- a/src/suyu/configuration/configure_input_player.cpp +++ b/src/suyu/configuration/configure_input_player.cpp @@ -293,11 +293,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i InputCommon::InputSubsystem* input_subsystem_, InputProfiles* profiles_, Core::HID::HIDCore& hid_core_, bool is_powered_on_, bool debug_) - : QWidget(parent), - ui(std::make_unique()), player_index{player_index_}, debug{debug_}, - is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_}, profiles(profiles_), - timeout_timer(std::make_unique()), - poll_timer(std::make_unique()), bottom_row{bottom_row_}, hid_core{hid_core_} { + : QWidget(parent), ui(std::make_unique()), + player_index{player_index_}, debug{debug_}, is_powered_on{is_powered_on_}, + input_subsystem{input_subsystem_}, profiles(profiles_), + timeout_timer(std::make_unique()), poll_timer(std::make_unique()), + bottom_row{bottom_row_}, hid_core{hid_core_} { if (player_index == 0) { auto* emulated_controller_p1 = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); diff --git a/src/suyu/configuration/configure_per_game.cpp b/src/suyu/configuration/configure_per_game.cpp index 2cadba72ff..168b5017a1 100644 --- a/src/suyu/configuration/configure_per_game.cpp +++ b/src/suyu/configuration/configure_per_game.cpp @@ -44,8 +44,8 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name, std::vector& vk_device_records, Core::System& system_) - : QDialog(parent), - ui(std::make_unique()), title_id{title_id_}, system{system_}, + : QDialog(parent), ui(std::make_unique()), title_id{title_id_}, + system{system_}, builder{std::make_unique(this, !system_.IsPoweredOn())}, tab_group{std::make_shared>()} { const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name)); diff --git a/src/suyu/configuration/configure_per_game_addons.cpp b/src/suyu/configuration/configure_per_game_addons.cpp index 79f2cd2c6a..3a075ac0ee 100644 --- a/src/suyu/configuration/configure_per_game_addons.cpp +++ b/src/suyu/configuration/configure_per_game_addons.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include +#include #include #include @@ -11,12 +13,19 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include "common/fs/fs.h" #include "common/fs/path_util.h" #include "core/core.h" #include "core/file_sys/patch_manager.h" -#include "core/file_sys/xts_archive.h" #include "core/loader/loader.h" #include "suyu/configuration/configure_input.h" #include "suyu/configuration/configure_per_game_addons.h" @@ -63,6 +72,16 @@ ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* p connect(item_model, &QStandardItemModel::itemChanged, [] { UISettings::values.is_game_list_reload_pending.exchange(true); }); + + connect(tree_view, &QTreeView::clicked, this, &ConfigurePerGameAddons::OnPatchSelected); + + connect(ui->new_btn, &QPushButton::clicked, this, &ConfigurePerGameAddons::OnPatchCreateClick); + connect(ui->edit_btn, &QPushButton::clicked, this, &ConfigurePerGameAddons::OnPatchEditClick); + connect(ui->remove_btn, &QPushButton::clicked, this, + &ConfigurePerGameAddons::OnPatchRemoveClick); + + connect(ui->folder_btn, &QPushButton::clicked, this, + &ConfigurePerGameAddons::OnPatchOpenFolder); } ConfigurePerGameAddons::~ConfigurePerGameAddons() = default; @@ -119,10 +138,11 @@ void ConfigurePerGameAddons::LoadConfiguration() { FileSys::VirtualFile update_raw; loader->ReadUpdateRaw(update_raw); + patches = pm.GetPatches(update_raw); const auto& disabled = Settings::values.disabled_addons[title_id]; - for (const auto& patch : pm.GetPatches(update_raw)) { + for (const auto& patch : patches) { const auto name = QString::fromStdString(patch.name); auto* const first_item = new QStandardItem; @@ -141,3 +161,148 @@ void ConfigurePerGameAddons::LoadConfiguration() { tree_view->resizeColumnToContents(1); } + +void ConfigurePerGameAddons::ReloadList() { + // Clear all items and selection + item_model->setRowCount(0); + list_items.clear(); + selected_patch = std::nullopt; + + // Remove the cache to ensure we'll recreate it + Common::FS::RemoveFile(Common::FS::GetSuyuPath(Common::FS::SuyuPath::CacheDir) / "game_list" / + fmt::format("{:016X}.pv.txt", title_id)); + + // Reload stuff + UISettings::values.is_game_list_reload_pending.exchange(true); + UISettings::values.is_game_list_reload_pending.notify_all(); + LoadConfiguration(); + ApplyConfiguration(); +} + +void ConfigurePerGameAddons::OnPatchSelected(const QModelIndex& selectedIndex) { + QModelIndexList indexes = tree_view->selectionModel()->selectedIndexes(); + if (indexes.size() == 0) { + // Nothing selected + ui->edit_btn->setEnabled(false); + ui->remove_btn->setEnabled(false); + return; + } + + QStandardItemModel* model = (QStandardItemModel*)tree_view->model(); + QStandardItem* item = model->itemFromIndex(selectedIndex.siblingAtColumn(0)); + + std::string patch_name = item->text().toStdString(); + selected_patch = std::nullopt; + + for (const auto& patch : patches) { + if (patch.name != patch_name) + continue; + if (patch.version != "IPSwitch") + continue; + + selected_patch = patch; + } + + if (!selected_patch || !selected_patch->file_path) { + // Either patch not found or selected isn't a patch + ui->edit_btn->setEnabled(false); + ui->remove_btn->setEnabled(false); + return; + } + + ui->edit_btn->setEnabled(true); + ui->remove_btn->setEnabled(true); +} + +void ConfigurePerGameAddons::OnPatchCreateClick(bool checked) { + std::filesystem::path addon_path = + Common::FS::GetSuyuPath(Common::FS::SuyuPath::LoadDir) / fmt::format("{:016X}", title_id); + + QDialog dialog(this); + dialog.setWindowTitle(QString::fromStdString("New Patch")); + + QFormLayout form(&dialog); + form.addRow( + new QLabel(QString::fromStdString("Enter the name of the patch that will be created"))); + + QLineEdit* lineEdit = new QLineEdit(&dialog); + form.addRow(QString::fromStdString("Patch Name"), lineEdit); + + QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, + &dialog); + + form.addRow(&buttonBox); + QObject::connect(&buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept())); + QObject::connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject())); + + if (dialog.exec() == QDialog::Accepted) { + std::filesystem::path addon_root_path = addon_path / lineEdit->text().toStdString(); + std::filesystem::path addon_exefs_path = addon_root_path / "exefs"; + std::filesystem::path addon_file_path = addon_exefs_path / "patch.pchtxt"; + + // Create the folders + if (!Common::FS::CreateDir(addon_root_path)) { + LOG_ERROR(Core, "Could not create new addon root path at {}", + addon_root_path.generic_string()); + return; + } + + if (!Common::FS::CreateDir(addon_exefs_path)) { + LOG_ERROR(Core, "Could not create new addon root path at {}", + addon_root_path.generic_string()); + return; + } + + // Create the patch file + std::ofstream patch_file(addon_file_path); + patch_file << "# Place your patches below" << std::endl; + patch_file.close(); + + // Reload everything + ReloadList(); + } +} + +void ConfigurePerGameAddons::OnPatchEditClick(bool checked) { + if (!selected_patch || !selected_patch->file_path) { + // Either no patch selected or selected patch somehow doesn't have a file? + return; + } + + QDesktopServices::openUrl( + QUrl::fromLocalFile(QString::fromStdString(selected_patch->file_path.value()))); +} + +void ConfigurePerGameAddons::OnPatchRemoveClick(bool checked) { + if (!selected_patch || !selected_patch->file_path || !selected_patch->root_path) { + // Either no patch selected or selected patch somehow doesn't have a file? + return; + } + + QMessageBox::StandardButton reply; + reply = QMessageBox::question( + this, QString::fromStdString("Remove patch confirmation"), + QString::fromStdString( + "Are you sure you want to remove the patch '%1'? This action is permanent!") + .arg(QString::fromStdString(selected_patch->name)), + QMessageBox::Yes | QMessageBox::No); + + if (reply != QMessageBox::Yes) { + return; + } + + // Remove the patch then reload + if (!Common::FS::RemoveDirRecursively(selected_patch->root_path.value_or("Invalid Path"))) { + LOG_ERROR(Core, "Could not create new addon root path at {}", + selected_patch->root_path.value_or("Invalid Path")); + } + + ReloadList(); +} + +void ConfigurePerGameAddons::OnPatchOpenFolder(bool checked) { + std::filesystem::path path = + Common::FS::GetSuyuPath(Common::FS::SuyuPath::LoadDir) / fmt::format("{:016X}", title_id); + + QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(path.generic_string()))); +} diff --git a/src/suyu/configuration/configure_per_game_addons.h b/src/suyu/configuration/configure_per_game_addons.h index 32dc5dde62..8aa1c68e97 100644 --- a/src/suyu/configuration/configure_per_game_addons.h +++ b/src/suyu/configuration/configure_per_game_addons.h @@ -7,7 +7,9 @@ #include #include +#include +#include "core/file_sys/patch_manager.h" #include "core/file_sys/vfs/vfs_types.h" namespace Core { @@ -43,6 +45,7 @@ private: void RetranslateUI(); void LoadConfiguration(); + void ReloadList(); std::unique_ptr ui; FileSys::VirtualFile file; @@ -54,5 +57,15 @@ private: std::vector> list_items; + std::optional selected_patch; + std::vector patches; + Core::System& system; + +private slots: + void OnPatchSelected(const QModelIndex& selectedIndex); + void OnPatchCreateClick(bool checked = false); + void OnPatchEditClick(bool checked = false); + void OnPatchRemoveClick(bool checked = false); + void OnPatchOpenFolder(bool checked = false); }; diff --git a/src/suyu/configuration/configure_per_game_addons.ui b/src/suyu/configuration/configure_per_game_addons.ui index f9cf6f2c31..bafeeb6e9e 100644 --- a/src/suyu/configuration/configure_per_game_addons.ui +++ b/src/suyu/configuration/configure_per_game_addons.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 300 + 482 + 316 @@ -18,21 +18,63 @@ - - - true - - - - - 0 - 0 - 380 - 280 - - - - + + + + + true + + + + + 0 + 0 + 460 + 262 + + + + + + + + + + + New Patch + + + + + + + false + + + Edit Patch + + + + + + + false + + + Remove Patch + + + + + + + Open Folder + + + + + + diff --git a/src/suyu/configuration/shared_widget.cpp b/src/suyu/configuration/shared_widget.cpp index 76a6b417cd..1e77bb62c3 100644 --- a/src/suyu/configuration/shared_widget.cpp +++ b/src/suyu/configuration/shared_widget.cpp @@ -766,8 +766,8 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati Builder::Builder(QWidget* parent_, bool runtime_lock_) : translations{InitializeTranslations(parent_)}, - combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, runtime_lock{ - runtime_lock_} {} + combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, + runtime_lock{runtime_lock_} {} Builder::~Builder() = default; diff --git a/src/suyu/game_list_worker.cpp b/src/suyu/game_list_worker.cpp index 9243464780..704368190a 100644 --- a/src/suyu/game_list_worker.cpp +++ b/src/suyu/game_list_worker.cpp @@ -234,8 +234,8 @@ GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs_, const PlayTime::PlayTimeManager& play_time_manager_, Core::System& system_) : vfs{std::move(vfs_)}, provider{provider_}, game_dirs{game_dirs_}, - compatibility_list{compatibility_list_}, play_time_manager{play_time_manager_}, system{ - system_} { + compatibility_list{compatibility_list_}, play_time_manager{play_time_manager_}, + system{system_} { // We want the game list to manage our lifetime. setAutoDelete(false); } diff --git a/src/suyu/multiplayer/direct_connect.cpp b/src/suyu/multiplayer/direct_connect.cpp index 5d5cb7aabc..7adde5168d 100644 --- a/src/suyu/multiplayer/direct_connect.cpp +++ b/src/suyu/multiplayer/direct_connect.cpp @@ -24,8 +24,8 @@ enum class ConnectionType : u8 { TraversalServer, IP }; DirectConnectWindow::DirectConnectWindow(Core::System& system_, QWidget* parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), - ui(std::make_unique()), system{system_}, room_network{ - system.GetRoomNetwork()} { + ui(std::make_unique()), system{system_}, + room_network{system.GetRoomNetwork()} { ui->setupUi(this); diff --git a/src/suyu/multiplayer/host_room.cpp b/src/suyu/multiplayer/host_room.cpp index 6c71454c8e..66733837bc 100644 --- a/src/suyu/multiplayer/host_room.cpp +++ b/src/suyu/multiplayer/host_room.cpp @@ -31,9 +31,8 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list, std::shared_ptr session, Core::System& system_) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), - ui(std::make_unique()), - announce_multiplayer_session(session), system{system_}, room_network{ - system.GetRoomNetwork()} { + ui(std::make_unique()), announce_multiplayer_session(session), system{system_}, + room_network{system.GetRoomNetwork()} { ui->setupUi(this); // set up validation for all of the fields diff --git a/src/suyu/multiplayer/lobby.cpp b/src/suyu/multiplayer/lobby.cpp index b4c0596632..9fca35461c 100644 --- a/src/suyu/multiplayer/lobby.cpp +++ b/src/suyu/multiplayer/lobby.cpp @@ -27,9 +27,8 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list, std::shared_ptr session, Core::System& system_) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), - ui(std::make_unique()), - announce_multiplayer_session(session), system{system_}, room_network{ - system.GetRoomNetwork()} { + ui(std::make_unique()), announce_multiplayer_session(session), system{system_}, + room_network{system.GetRoomNetwork()} { ui->setupUi(this); // setup the watcher for background connections diff --git a/src/video_core/cdma_pusher.cpp b/src/video_core/cdma_pusher.cpp index 3bcf1b0664..24d73bd843 100644 --- a/src/video_core/cdma_pusher.cpp +++ b/src/video_core/cdma_pusher.cpp @@ -18,8 +18,8 @@ namespace Tegra { CDmaPusher::CDmaPusher(Host1x::Host1x& host1x_, s32 id) : host1x{host1x_}, memory_manager{host1x.GMMU()}, - host_processor{std::make_unique(host1x_)}, current_class{ - static_cast(id)} { + host_processor{std::make_unique(host1x_)}, + current_class{static_cast(id)} { thread = std::jthread([this](std::stop_token stop_token) { ProcessEntries(stop_token); }); } diff --git a/src/video_core/dma_pusher.cpp b/src/video_core/dma_pusher.cpp index fb2060ca43..33ef54edef 100644 --- a/src/video_core/dma_pusher.cpp +++ b/src/video_core/dma_pusher.cpp @@ -18,8 +18,8 @@ constexpr u32 ComputeInline = 0x6D; DmaPusher::DmaPusher(Core::System& system_, GPU& gpu_, MemoryManager& memory_manager_, Control::ChannelState& channel_state_) - : gpu{gpu_}, system{system_}, memory_manager{memory_manager_}, puller{gpu_, memory_manager_, - *this, channel_state_} {} + : gpu{gpu_}, system{system_}, memory_manager{memory_manager_}, + puller{gpu_, memory_manager_, *this, channel_state_} {} DmaPusher::~DmaPusher() = default; diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 0d47b032c8..5e070fa3b4 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -24,9 +24,8 @@ constexpr u32 MacroRegistersStart = 0xE00; Maxwell3D::Maxwell3D(Core::System& system_, MemoryManager& memory_manager_) : draw_manager{std::make_unique(this)}, system{system_}, - memory_manager{memory_manager_}, macro_engine{GetMacroEngine(*this)}, upload_state{ - memory_manager, - regs.upload} { + memory_manager{memory_manager_}, macro_engine{GetMacroEngine(*this)}, + upload_state{memory_manager, regs.upload} { dirty.flags.flip(); InitializeRegisterDefaults(); execution_mask.reset(); diff --git a/src/video_core/engines/puller.cpp b/src/video_core/engines/puller.cpp index 8dd34c04ab..415bac9c98 100644 --- a/src/video_core/engines/puller.cpp +++ b/src/video_core/engines/puller.cpp @@ -21,8 +21,8 @@ namespace Tegra::Engines { Puller::Puller(GPU& gpu_, MemoryManager& memory_manager_, DmaPusher& dma_pusher_, Control::ChannelState& channel_state_) - : gpu{gpu_}, memory_manager{memory_manager_}, dma_pusher{dma_pusher_}, channel_state{ - channel_state_} {} + : gpu{gpu_}, memory_manager{memory_manager_}, dma_pusher{dma_pusher_}, + channel_state{channel_state_} {} Puller::~Puller() = default; diff --git a/src/video_core/host1x/codecs/decoder.cpp b/src/video_core/host1x/codecs/decoder.cpp old mode 100755 new mode 100644 index 49a601969c..c62c11e28f --- a/src/video_core/host1x/codecs/decoder.cpp +++ b/src/video_core/host1x/codecs/decoder.cpp @@ -11,8 +11,8 @@ namespace Tegra { Decoder::Decoder(Host1x::Host1x& host1x_, s32 id_, const Host1x::NvdecCommon::NvdecRegisters& regs_, Host1x::FrameQueue& frame_queue_) - : host1x(host1x_), memory_manager{host1x.GMMU()}, regs{regs_}, id{id_}, frame_queue{ - frame_queue_} {} + : host1x(host1x_), memory_manager{host1x.GMMU()}, regs{regs_}, id{id_}, + frame_queue{frame_queue_} {} Decoder::~Decoder() = default; diff --git a/src/video_core/host1x/host1x.cpp b/src/video_core/host1x/host1x.cpp index 293bca6d79..7499ee77ec 100644 --- a/src/video_core/host1x/host1x.cpp +++ b/src/video_core/host1x/host1x.cpp @@ -9,8 +9,8 @@ namespace Tegra::Host1x { Host1x::Host1x(Core::System& system_) - : system{system_}, syncpoint_manager{}, - memory_manager(system.DeviceMemory()), gmmu_manager{system, memory_manager, 32, 0, 12}, + : system{system_}, syncpoint_manager{}, memory_manager(system.DeviceMemory()), + gmmu_manager{system, memory_manager, 32, 0, 12}, allocator{std::make_unique>(1 << 12)} {} Host1x::~Host1x() = default; diff --git a/src/video_core/host1x/vic.cpp b/src/video_core/host1x/vic.cpp index 3ad56bb80c..2d06580609 100644 --- a/src/video_core/host1x/vic.cpp +++ b/src/video_core/host1x/vic.cpp @@ -94,8 +94,8 @@ void SwizzleSurface(std::span output, u32 out_stride, std::span in } // namespace Vic::Vic(Host1x& host1x_, s32 id_, u32 syncpt, FrameQueue& frame_queue_) - : CDmaPusher{host1x_, id_}, id{id_}, syncpoint{syncpt}, - frame_queue{frame_queue_}, has_sse41{HasSSE41()} { + : CDmaPusher{host1x_, id_}, id{id_}, syncpoint{syncpt}, frame_queue{frame_queue_}, + has_sse41{HasSSE41()} { LOG_INFO(HW_GPU, "Created vic {}", id); } diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index ffafc48eff..aa60938119 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -28,8 +28,8 @@ MemoryManager::MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& split_address{split_address_}, page_bits{page_bits_}, big_page_bits{big_page_bits_}, entries{}, big_entries{}, page_table{address_space_bits, address_space_bits + page_bits - 38, page_bits != big_page_bits ? page_bits : 0}, - kind_map{PTEKind::INVALID}, unique_identifier{unique_identifier_generator.fetch_add( - 1, std::memory_order_acq_rel)}, + kind_map{PTEKind::INVALID}, + unique_identifier{unique_identifier_generator.fetch_add(1, std::memory_order_acq_rel)}, accumulator{std::make_unique()} { address_space_size = 1ULL << address_space_bits; page_size = 1ULL << page_bits; diff --git a/src/video_core/query_cache/query_cache.h b/src/video_core/query_cache/query_cache.h index 08b7790555..d4ee55dea0 100644 --- a/src/video_core/query_cache/query_cache.h +++ b/src/video_core/query_cache/query_cache.h @@ -115,8 +115,8 @@ struct QueryCacheBase::QueryCacheBaseImpl { QueryCacheBaseImpl(QueryCacheBase* owner_, VideoCore::RasterizerInterface& rasterizer_, Tegra::MaxwellDeviceMemoryManager& device_memory_, RuntimeType& runtime_, Tegra::GPU& gpu_) - : owner{owner_}, rasterizer{rasterizer_}, - device_memory{device_memory_}, runtime{runtime_}, gpu{gpu_} { + : owner{owner_}, rasterizer{rasterizer_}, device_memory{device_memory_}, runtime{runtime_}, + gpu{gpu_} { streamer_mask = 0; for (size_t i = 0; i < static_cast(QueryType::MaxQueryTypes); i++) { streamers[i] = runtime.GetStreamerInterface(static_cast(i)); diff --git a/src/video_core/renderer_opengl/gl_compute_pipeline.cpp b/src/video_core/renderer_opengl/gl_compute_pipeline.cpp index d705018607..bb974bfd2b 100644 --- a/src/video_core/renderer_opengl/gl_compute_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_compute_pipeline.cpp @@ -31,8 +31,8 @@ ComputePipeline::ComputePipeline(const Device& device, TextureCache& texture_cac BufferCache& buffer_cache_, ProgramManager& program_manager_, const Shader::Info& info_, std::string code, std::vector code_v, bool force_context_flush) - : texture_cache{texture_cache_}, buffer_cache{buffer_cache_}, - program_manager{program_manager_}, info{info_} { + : texture_cache{texture_cache_}, buffer_cache{buffer_cache_}, program_manager{program_manager_}, + info{info_} { switch (device.GetShaderBackend()) { case Settings::ShaderBackend::Glsl: source_program = CreateProgram(code, GL_COMPUTE_SHADER); diff --git a/src/video_core/renderer_opengl/gl_query_cache.cpp b/src/video_core/renderer_opengl/gl_query_cache.cpp index 2147d587f7..ca00d7c3b7 100644 --- a/src/video_core/renderer_opengl/gl_query_cache.cpp +++ b/src/video_core/renderer_opengl/gl_query_cache.cpp @@ -66,9 +66,8 @@ bool QueryCache::AnyCommandQueued() const noexcept { HostCounter::HostCounter(QueryCache& cache_, std::shared_ptr dependency_, VideoCore::QueryType type_) - : HostCounterBase{std::move(dependency_)}, cache{cache_}, type{type_}, query{ - cache.AllocateQuery( - type)} { + : HostCounterBase{std::move(dependency_)}, cache{cache_}, type{type_}, + query{cache.AllocateQuery(type)} { glBeginQuery(GetTarget(type), query.handle); } diff --git a/src/video_core/renderer_vulkan/present/fsr.cpp b/src/video_core/renderer_vulkan/present/fsr.cpp index 3f708be704..55606deb83 100644 --- a/src/video_core/renderer_vulkan/present/fsr.cpp +++ b/src/video_core/renderer_vulkan/present/fsr.cpp @@ -24,8 +24,8 @@ using PushConstants = std::array; FSR::FSR(const Device& device, MemoryAllocator& memory_allocator, size_t image_count, VkExtent2D extent) - : m_device{device}, m_memory_allocator{memory_allocator}, - m_image_count{image_count}, m_extent{extent} { + : m_device{device}, m_memory_allocator{memory_allocator}, m_image_count{image_count}, + m_extent{extent} { CreateImages(); CreateRenderPasses(); diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.cpp b/src/video_core/renderer_vulkan/vk_compute_pass.cpp index 617f92910c..6455e5eb75 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pass.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pass.cpp @@ -531,8 +531,8 @@ ASTCDecoderPass::ASTCDecoderPass(const Device& device_, Scheduler& scheduler_, ASTC_PASS_DESCRIPTOR_UPDATE_TEMPLATE_ENTRY, ASTC_BANK_INFO, COMPUTE_PUSH_CONSTANT_RANGE, ASTC_DECODER_COMP_SPV), scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_}, - compute_pass_descriptor_queue{compute_pass_descriptor_queue_}, memory_allocator{ - memory_allocator_} {} + compute_pass_descriptor_queue{compute_pass_descriptor_queue_}, + memory_allocator{memory_allocator_} {} ASTCDecoderPass::~ASTCDecoderPass() = default; diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index 73e585c2b7..689c7d760c 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp @@ -31,8 +31,8 @@ ComputePipeline::ComputePipeline(const Device& device_, vk::PipelineCache& pipel PipelineStatistics* pipeline_statistics, VideoCore::ShaderNotify* shader_notify, const Shader::Info& info_, vk::ShaderModule spv_module_) - : device{device_}, - pipeline_cache(pipeline_cache_), guest_descriptor_queue{guest_descriptor_queue_}, info{info_}, + : device{device_}, pipeline_cache(pipeline_cache_), + guest_descriptor_queue{guest_descriptor_queue_}, info{info_}, spv_module(std::move(spv_module_)) { if (shader_notify) { shader_notify->MarkShaderBuilding(); diff --git a/src/video_core/renderer_vulkan/vk_present_manager.cpp b/src/video_core/renderer_vulkan/vk_present_manager.cpp index 5e7518d968..8fcc5ede32 100644 --- a/src/video_core/renderer_vulkan/vk_present_manager.cpp +++ b/src/video_core/renderer_vulkan/vk_present_manager.cpp @@ -100,8 +100,8 @@ PresentManager::PresentManager(const vk::Instance& instance_, Swapchain& swapchain_, vk::SurfaceKHR& surface_) : instance{instance_}, render_window{render_window_}, device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_}, - surface{surface_}, blit_supported{CanBlitToSwapchain(device.GetPhysical(), - swapchain.GetImageViewFormat())}, + surface{surface_}, + blit_supported{CanBlitToSwapchain(device.GetPhysical(), swapchain.GetImageViewFormat())}, use_present_thread{Settings::values.async_presentation.GetValue()} { SetImageCount(); diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index a28296bdaf..6c25212819 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -1161,10 +1161,9 @@ struct QueryCacheRuntimeImpl { StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool) - : rasterizer{rasterizer_}, device_memory{device_memory_}, - buffer_cache{buffer_cache_}, device{device_}, - memory_allocator{memory_allocator_}, scheduler{scheduler_}, staging_pool{staging_pool_}, - guest_streamer(0, runtime), + : rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_}, + device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, + staging_pool{staging_pool_}, guest_streamer(0, runtime), sample_streamer(static_cast(QueryType::ZPassPixelCount64), runtime, rasterizer, device, scheduler, memory_allocator, compute_pass_descriptor_queue, descriptor_pool), diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp index 03a0b7280b..9f24741493 100644 --- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp @@ -49,8 +49,8 @@ size_t GetStreamBufferSize(const Device& device) { StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& memory_allocator_, Scheduler& scheduler_) : device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, - stream_buffer_size{GetStreamBufferSize(device)}, region_size{stream_buffer_size / - StagingBufferPool::NUM_SYNCS} { + stream_buffer_size{GetStreamBufferSize(device)}, + region_size{stream_buffer_size / StagingBufferPool::NUM_SYNCS} { VkBufferCreateInfo stream_ci = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = nullptr, diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 85ccd74774..cc2656ef70 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -29,331 +29,331 @@ namespace Vulkan { - using Tegra::Engines::Fermi2D; - using Tegra::Texture::SwizzleSource; - using Tegra::Texture::TextureMipmapFilter; - using VideoCommon::BufferImageCopy; - using VideoCommon::ImageFlagBits; - using VideoCommon::ImageInfo; - using VideoCommon::ImageType; - using VideoCommon::SubresourceRange; - using VideoCore::Surface::BytesPerBlock; - using VideoCore::Surface::IsPixelFormatASTC; - using VideoCore::Surface::IsPixelFormatInteger; - using VideoCore::Surface::SurfaceType; +using Tegra::Engines::Fermi2D; +using Tegra::Texture::SwizzleSource; +using Tegra::Texture::TextureMipmapFilter; +using VideoCommon::BufferImageCopy; +using VideoCommon::ImageFlagBits; +using VideoCommon::ImageInfo; +using VideoCommon::ImageType; +using VideoCommon::SubresourceRange; +using VideoCore::Surface::BytesPerBlock; +using VideoCore::Surface::IsPixelFormatASTC; +using VideoCore::Surface::IsPixelFormatInteger; +using VideoCore::Surface::SurfaceType; - namespace { - constexpr VkBorderColor ConvertBorderColor(const std::array& color) { - if (color == std::array{0, 0, 0, 0}) { - return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; - } else if (color == std::array{0, 0, 0, 1}) { - return VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK; - } else if (color == std::array{1, 1, 1, 1}) { - return VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; - } - if (color[0] + color[1] + color[2] > 1.35f) { - // If color elements are brighter than roughly 0.5 average, use white border - return VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; - } else if (color[3] > 0.5f) { - return VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK; - } else { - return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; - } +namespace { +constexpr VkBorderColor ConvertBorderColor(const std::array& color) { + if (color == std::array{0, 0, 0, 0}) { + return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; + } else if (color == std::array{0, 0, 0, 1}) { + return VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK; + } else if (color == std::array{1, 1, 1, 1}) { + return VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; + } + if (color[0] + color[1] + color[2] > 1.35f) { + // If color elements are brighter than roughly 0.5 average, use white border + return VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; + } else if (color[3] > 0.5f) { + return VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK; + } else { + return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; + } +} + +[[nodiscard]] VkImageType ConvertImageType(const ImageType type) { + switch (type) { + case ImageType::e1D: + return VK_IMAGE_TYPE_1D; + case ImageType::e2D: + case ImageType::Linear: + return VK_IMAGE_TYPE_2D; + case ImageType::e3D: + return VK_IMAGE_TYPE_3D; + case ImageType::Buffer: + break; + } + ASSERT_MSG(false, "Invalid image type={}", type); + return {}; +} + +[[nodiscard]] VkSampleCountFlagBits ConvertSampleCount(u32 num_samples) { + switch (num_samples) { + case 1: + return VK_SAMPLE_COUNT_1_BIT; + case 2: + return VK_SAMPLE_COUNT_2_BIT; + case 4: + return VK_SAMPLE_COUNT_4_BIT; + case 8: + return VK_SAMPLE_COUNT_8_BIT; + case 16: + return VK_SAMPLE_COUNT_16_BIT; + default: + ASSERT_MSG(false, "Invalid number of samples={}", num_samples); + return VK_SAMPLE_COUNT_1_BIT; + } +} + +[[nodiscard]] VkImageUsageFlags ImageUsageFlags(const MaxwellToVK::FormatInfo& info, + PixelFormat format) { + VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | + VK_IMAGE_USAGE_SAMPLED_BIT; + if (info.attachable) { + switch (VideoCore::Surface::GetFormatType(format)) { + case VideoCore::Surface::SurfaceType::ColorTexture: + usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; + break; + case VideoCore::Surface::SurfaceType::Depth: + case VideoCore::Surface::SurfaceType::Stencil: + case VideoCore::Surface::SurfaceType::DepthStencil: + usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; + break; + default: + ASSERT_MSG(false, "Invalid surface type"); + break; } + } + if (info.storage) { + usage |= VK_IMAGE_USAGE_STORAGE_BIT; + } + return usage; +} - [[nodiscard]] VkImageType ConvertImageType(const ImageType type) { - switch (type) { - case ImageType::e1D: - return VK_IMAGE_TYPE_1D; - case ImageType::e2D: - case ImageType::Linear: - return VK_IMAGE_TYPE_2D; - case ImageType::e3D: - return VK_IMAGE_TYPE_3D; - case ImageType::Buffer: - break; - } - ASSERT_MSG(false, "Invalid image type={}", type); - return {}; +[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info) { + const bool is_2d = (info.type == ImageType::e2D); + const bool is_3d = (info.type == ImageType::e3D); + const auto format_info = + MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, info.format); + VkImageCreateFlags flags{}; + if (is_2d && info.resources.layers >= 6 && info.size.width == info.size.height && + !device.HasBrokenCubeImageCompatibility()) { + flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; + } + + // fix moltenVK issues with some 3D games + // credit to Jarrod Norwell from Sudachi https://github.com/jarrodnorwell/Sudachi + auto usage = ImageUsageFlags(format_info, info.format); + if (is_3d) { + flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT; + usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; + } + const auto [samples_x, samples_y] = VideoCommon::SamplesLog2(info.num_samples); + return VkImageCreateInfo{ + .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, + .pNext = nullptr, + .flags = flags, + .imageType = ConvertImageType(info.type), + .format = format_info.format, + .extent{ + .width = info.size.width >> samples_x, + .height = info.size.height >> samples_y, + .depth = info.size.depth, + }, + .mipLevels = static_cast(info.resources.levels), + .arrayLayers = static_cast(info.resources.layers), + .samples = ConvertSampleCount(info.num_samples), + .tiling = VK_IMAGE_TILING_OPTIMAL, + .usage = usage, + .sharingMode = VK_SHARING_MODE_EXCLUSIVE, + .queueFamilyIndexCount = 0, + .pQueueFamilyIndices = nullptr, + .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, + }; +} + +[[nodiscard]] vk::Image MakeImage(const Device& device, const MemoryAllocator& allocator, + const ImageInfo& info, std::span view_formats) { + const bool is_buffer = (info.type == ImageType::Buffer); + if (is_buffer) { + return vk::Image{}; + } + VkImageCreateInfo image_ci = MakeImageCreateInfo(device, info); + const VkImageFormatListCreateInfo image_format_list = { + .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO, + .pNext = nullptr, + .viewFormatCount = static_cast(view_formats.size()), + .pViewFormats = view_formats.data(), + }; + if (view_formats.size() > 1) { + image_ci.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; + if (device.IsKhrImageFormatListSupported()) { + image_ci.pNext = &image_format_list; } + } + return allocator.CreateImage(image_ci); +} - [[nodiscard]] VkSampleCountFlagBits ConvertSampleCount(u32 num_samples) { - switch (num_samples) { - case 1: - return VK_SAMPLE_COUNT_1_BIT; - case 2: - return VK_SAMPLE_COUNT_2_BIT; - case 4: - return VK_SAMPLE_COUNT_4_BIT; - case 8: - return VK_SAMPLE_COUNT_8_BIT; - case 16: - return VK_SAMPLE_COUNT_16_BIT; - default: - ASSERT_MSG(false, "Invalid number of samples={}", num_samples); - return VK_SAMPLE_COUNT_1_BIT; - } - } +[[nodiscard]] vk::ImageView MakeStorageView(const vk::Device& device, u32 level, VkImage image, + VkFormat format) { + static constexpr VkImageViewUsageCreateInfo storage_image_view_usage_create_info{ + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, + .pNext = nullptr, + .usage = VK_IMAGE_USAGE_STORAGE_BIT, + }; + return device.CreateImageView(VkImageViewCreateInfo{ + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + .pNext = &storage_image_view_usage_create_info, + .flags = 0, + .image = image, + .viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY, + .format = format, + .components{ + .r = VK_COMPONENT_SWIZZLE_IDENTITY, + .g = VK_COMPONENT_SWIZZLE_IDENTITY, + .b = VK_COMPONENT_SWIZZLE_IDENTITY, + .a = VK_COMPONENT_SWIZZLE_IDENTITY, + }, + .subresourceRange{ + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = level, + .levelCount = 1, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, + }, + }); +} - [[nodiscard]] VkImageUsageFlags ImageUsageFlags(const MaxwellToVK::FormatInfo& info, - PixelFormat format) { - VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | - VK_IMAGE_USAGE_SAMPLED_BIT; - if (info.attachable) { - switch (VideoCore::Surface::GetFormatType(format)) { - case VideoCore::Surface::SurfaceType::ColorTexture: - usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; - break; - case VideoCore::Surface::SurfaceType::Depth: - case VideoCore::Surface::SurfaceType::Stencil: - case VideoCore::Surface::SurfaceType::DepthStencil: - usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; - break; - default: - ASSERT_MSG(false, "Invalid surface type"); - break; - } - } - if (info.storage) { - usage |= VK_IMAGE_USAGE_STORAGE_BIT; - } - return usage; - } +[[nodiscard]] VkImageAspectFlags ImageAspectMask(PixelFormat format) { + switch (VideoCore::Surface::GetFormatType(format)) { + case VideoCore::Surface::SurfaceType::ColorTexture: + return VK_IMAGE_ASPECT_COLOR_BIT; + case VideoCore::Surface::SurfaceType::Depth: + return VK_IMAGE_ASPECT_DEPTH_BIT; + case VideoCore::Surface::SurfaceType::Stencil: + return VK_IMAGE_ASPECT_STENCIL_BIT; + case VideoCore::Surface::SurfaceType::DepthStencil: + return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + default: + ASSERT_MSG(false, "Invalid surface type"); + return VkImageAspectFlags{}; + } +} - [[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info) { - const bool is_2d = (info.type == ImageType::e2D); - const bool is_3d = (info.type == ImageType::e3D); - const auto format_info = - MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, info.format); - VkImageCreateFlags flags{}; - if (is_2d && info.resources.layers >= 6 && info.size.width == info.size.height && - !device.HasBrokenCubeImageCompatibility()) { - flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; - } +[[nodiscard]] VkImageAspectFlags ImageViewAspectMask(const VideoCommon::ImageViewInfo& info) { + if (info.IsRenderTarget()) { + return ImageAspectMask(info.format); + } + bool any_r = + std::ranges::any_of(info.Swizzle(), [](SwizzleSource s) { return s == SwizzleSource::R; }); + switch (info.format) { + case PixelFormat::D24_UNORM_S8_UINT: + case PixelFormat::D32_FLOAT_S8_UINT: + // R = depth, G = stencil + return any_r ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT; + case PixelFormat::S8_UINT_D24_UNORM: + // R = stencil, G = depth + return any_r ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; + case PixelFormat::D16_UNORM: + case PixelFormat::D32_FLOAT: + case PixelFormat::X8_D24_UNORM: + return VK_IMAGE_ASPECT_DEPTH_BIT; + case PixelFormat::S8_UINT: + return VK_IMAGE_ASPECT_STENCIL_BIT; + default: + return VK_IMAGE_ASPECT_COLOR_BIT; + } +} - // fix moltenVK issues with some 3D games - // credit to Jarrod Norwell from Sudachi https://github.com/jarrodnorwell/Sudachi - auto usage = ImageUsageFlags(format_info, info.format); - if (is_3d) { - flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT; - usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; - } - const auto [samples_x, samples_y] = VideoCommon::SamplesLog2(info.num_samples); - return VkImageCreateInfo{ - .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, - .pNext = nullptr, - .flags = flags, - .imageType = ConvertImageType(info.type), - .format = format_info.format, - .extent{ - .width = info.size.width >> samples_x, - .height = info.size.height >> samples_y, - .depth = info.size.depth, - }, - .mipLevels = static_cast(info.resources.levels), - .arrayLayers = static_cast(info.resources.layers), - .samples = ConvertSampleCount(info.num_samples), - .tiling = VK_IMAGE_TILING_OPTIMAL, - .usage = usage, - .sharingMode = VK_SHARING_MODE_EXCLUSIVE, - .queueFamilyIndexCount = 0, - .pQueueFamilyIndices = nullptr, - .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, - }; - } +[[nodiscard]] VkComponentSwizzle ComponentSwizzle(SwizzleSource swizzle) { + switch (swizzle) { + case SwizzleSource::Zero: + return VK_COMPONENT_SWIZZLE_ZERO; + case SwizzleSource::R: + return VK_COMPONENT_SWIZZLE_R; + case SwizzleSource::G: + return VK_COMPONENT_SWIZZLE_G; + case SwizzleSource::B: + return VK_COMPONENT_SWIZZLE_B; + case SwizzleSource::A: + return VK_COMPONENT_SWIZZLE_A; + case SwizzleSource::OneFloat: + case SwizzleSource::OneInt: + return VK_COMPONENT_SWIZZLE_ONE; + } + ASSERT_MSG(false, "Invalid swizzle={}", swizzle); + return VK_COMPONENT_SWIZZLE_ZERO; +} - [[nodiscard]] vk::Image MakeImage(const Device& device, const MemoryAllocator& allocator, - const ImageInfo& info, std::span view_formats) { - const bool is_buffer = (info.type == ImageType::Buffer); - if (is_buffer) { - return vk::Image{}; - } - VkImageCreateInfo image_ci = MakeImageCreateInfo(device, info); - const VkImageFormatListCreateInfo image_format_list = { - .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO, - .pNext = nullptr, - .viewFormatCount = static_cast(view_formats.size()), - .pViewFormats = view_formats.data(), - }; - if (view_formats.size() > 1) { - image_ci.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; - if (device.IsKhrImageFormatListSupported()) { - image_ci.pNext = &image_format_list; - } - } - return allocator.CreateImage(image_ci); - } +[[nodiscard]] VkImageViewType ImageViewType(Shader::TextureType type) { + switch (type) { + case Shader::TextureType::Color1D: + return VK_IMAGE_VIEW_TYPE_1D; + case Shader::TextureType::Color2D: + case Shader::TextureType::Color2DRect: + return VK_IMAGE_VIEW_TYPE_2D; + case Shader::TextureType::ColorCube: + return VK_IMAGE_VIEW_TYPE_CUBE; + case Shader::TextureType::Color3D: + return VK_IMAGE_VIEW_TYPE_3D; + case Shader::TextureType::ColorArray1D: + return VK_IMAGE_VIEW_TYPE_1D_ARRAY; + case Shader::TextureType::ColorArray2D: + return VK_IMAGE_VIEW_TYPE_2D_ARRAY; + case Shader::TextureType::ColorArrayCube: + return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; + case Shader::TextureType::Buffer: + ASSERT_MSG(false, "Texture buffers can't be image views"); + return VK_IMAGE_VIEW_TYPE_1D; + } + ASSERT_MSG(false, "Invalid image view type={}", type); + return VK_IMAGE_VIEW_TYPE_2D; +} - [[nodiscard]] vk::ImageView MakeStorageView(const vk::Device& device, u32 level, VkImage image, - VkFormat format) { - static constexpr VkImageViewUsageCreateInfo storage_image_view_usage_create_info{ - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, - .pNext = nullptr, - .usage = VK_IMAGE_USAGE_STORAGE_BIT, - }; - return device.CreateImageView(VkImageViewCreateInfo{ - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - .pNext = &storage_image_view_usage_create_info, - .flags = 0, - .image = image, - .viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY, - .format = format, - .components{ - .r = VK_COMPONENT_SWIZZLE_IDENTITY, - .g = VK_COMPONENT_SWIZZLE_IDENTITY, - .b = VK_COMPONENT_SWIZZLE_IDENTITY, - .a = VK_COMPONENT_SWIZZLE_IDENTITY, - }, - .subresourceRange{ - .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - .baseMipLevel = level, - .levelCount = 1, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, - }); - } +[[nodiscard]] VkImageViewType ImageViewType(VideoCommon::ImageViewType type) { + switch (type) { + case VideoCommon::ImageViewType::e1D: + return VK_IMAGE_VIEW_TYPE_1D; + case VideoCommon::ImageViewType::e2D: + case VideoCommon::ImageViewType::Rect: + return VK_IMAGE_VIEW_TYPE_2D; + case VideoCommon::ImageViewType::Cube: + return VK_IMAGE_VIEW_TYPE_CUBE; + case VideoCommon::ImageViewType::e3D: + return VK_IMAGE_VIEW_TYPE_3D; + case VideoCommon::ImageViewType::e1DArray: + return VK_IMAGE_VIEW_TYPE_1D_ARRAY; + case VideoCommon::ImageViewType::e2DArray: + return VK_IMAGE_VIEW_TYPE_2D_ARRAY; + case VideoCommon::ImageViewType::CubeArray: + return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; + case VideoCommon::ImageViewType::Buffer: + ASSERT_MSG(false, "Texture buffers can't be image views"); + return VK_IMAGE_VIEW_TYPE_1D; + } + ASSERT_MSG(false, "Invalid image view type={}", type); + return VK_IMAGE_VIEW_TYPE_2D; +} - [[nodiscard]] VkImageAspectFlags ImageAspectMask(PixelFormat format) { - switch (VideoCore::Surface::GetFormatType(format)) { - case VideoCore::Surface::SurfaceType::ColorTexture: - return VK_IMAGE_ASPECT_COLOR_BIT; - case VideoCore::Surface::SurfaceType::Depth: - return VK_IMAGE_ASPECT_DEPTH_BIT; - case VideoCore::Surface::SurfaceType::Stencil: - return VK_IMAGE_ASPECT_STENCIL_BIT; - case VideoCore::Surface::SurfaceType::DepthStencil: - return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; - default: - ASSERT_MSG(false, "Invalid surface type"); - return VkImageAspectFlags{}; - } - } +[[nodiscard]] VkImageSubresourceLayers MakeImageSubresourceLayers( + VideoCommon::SubresourceLayers subresource, VkImageAspectFlags aspect_mask) { + return VkImageSubresourceLayers{ + .aspectMask = aspect_mask, + .mipLevel = static_cast(subresource.base_level), + .baseArrayLayer = static_cast(subresource.base_layer), + .layerCount = static_cast(subresource.num_layers), + }; +} - [[nodiscard]] VkImageAspectFlags ImageViewAspectMask(const VideoCommon::ImageViewInfo& info) { - if (info.IsRenderTarget()) { - return ImageAspectMask(info.format); - } - bool any_r = - std::ranges::any_of(info.Swizzle(), [](SwizzleSource s) { return s == SwizzleSource::R; }); - switch (info.format) { - case PixelFormat::D24_UNORM_S8_UINT: - case PixelFormat::D32_FLOAT_S8_UINT: - // R = depth, G = stencil - return any_r ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT; - case PixelFormat::S8_UINT_D24_UNORM: - // R = stencil, G = depth - return any_r ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; - case PixelFormat::D16_UNORM: - case PixelFormat::D32_FLOAT: - case PixelFormat::X8_D24_UNORM: - return VK_IMAGE_ASPECT_DEPTH_BIT; - case PixelFormat::S8_UINT: - return VK_IMAGE_ASPECT_STENCIL_BIT; - default: - return VK_IMAGE_ASPECT_COLOR_BIT; - } - } +[[nodiscard]] VkOffset3D MakeOffset3D(VideoCommon::Offset3D offset3d) { + return VkOffset3D{ + .x = offset3d.x, + .y = offset3d.y, + .z = offset3d.z, + }; +} - [[nodiscard]] VkComponentSwizzle ComponentSwizzle(SwizzleSource swizzle) { - switch (swizzle) { - case SwizzleSource::Zero: - return VK_COMPONENT_SWIZZLE_ZERO; - case SwizzleSource::R: - return VK_COMPONENT_SWIZZLE_R; - case SwizzleSource::G: - return VK_COMPONENT_SWIZZLE_G; - case SwizzleSource::B: - return VK_COMPONENT_SWIZZLE_B; - case SwizzleSource::A: - return VK_COMPONENT_SWIZZLE_A; - case SwizzleSource::OneFloat: - case SwizzleSource::OneInt: - return VK_COMPONENT_SWIZZLE_ONE; - } - ASSERT_MSG(false, "Invalid swizzle={}", swizzle); - return VK_COMPONENT_SWIZZLE_ZERO; - } +[[nodiscard]] VkExtent3D MakeExtent3D(VideoCommon::Extent3D extent3d) { + return VkExtent3D{ + .width = static_cast(extent3d.width), + .height = static_cast(extent3d.height), + .depth = static_cast(extent3d.depth), + }; +} - [[nodiscard]] VkImageViewType ImageViewType(Shader::TextureType type) { - switch (type) { - case Shader::TextureType::Color1D: - return VK_IMAGE_VIEW_TYPE_1D; - case Shader::TextureType::Color2D: - case Shader::TextureType::Color2DRect: - return VK_IMAGE_VIEW_TYPE_2D; - case Shader::TextureType::ColorCube: - return VK_IMAGE_VIEW_TYPE_CUBE; - case Shader::TextureType::Color3D: - return VK_IMAGE_VIEW_TYPE_3D; - case Shader::TextureType::ColorArray1D: - return VK_IMAGE_VIEW_TYPE_1D_ARRAY; - case Shader::TextureType::ColorArray2D: - return VK_IMAGE_VIEW_TYPE_2D_ARRAY; - case Shader::TextureType::ColorArrayCube: - return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; - case Shader::TextureType::Buffer: - ASSERT_MSG(false, "Texture buffers can't be image views"); - return VK_IMAGE_VIEW_TYPE_1D; - } - ASSERT_MSG(false, "Invalid image view type={}", type); - return VK_IMAGE_VIEW_TYPE_2D; - } - - [[nodiscard]] VkImageViewType ImageViewType(VideoCommon::ImageViewType type) { - switch (type) { - case VideoCommon::ImageViewType::e1D: - return VK_IMAGE_VIEW_TYPE_1D; - case VideoCommon::ImageViewType::e2D: - case VideoCommon::ImageViewType::Rect: - return VK_IMAGE_VIEW_TYPE_2D; - case VideoCommon::ImageViewType::Cube: - return VK_IMAGE_VIEW_TYPE_CUBE; - case VideoCommon::ImageViewType::e3D: - return VK_IMAGE_VIEW_TYPE_3D; - case VideoCommon::ImageViewType::e1DArray: - return VK_IMAGE_VIEW_TYPE_1D_ARRAY; - case VideoCommon::ImageViewType::e2DArray: - return VK_IMAGE_VIEW_TYPE_2D_ARRAY; - case VideoCommon::ImageViewType::CubeArray: - return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; - case VideoCommon::ImageViewType::Buffer: - ASSERT_MSG(false, "Texture buffers can't be image views"); - return VK_IMAGE_VIEW_TYPE_1D; - } - ASSERT_MSG(false, "Invalid image view type={}", type); - return VK_IMAGE_VIEW_TYPE_2D; - } - - [[nodiscard]] VkImageSubresourceLayers MakeImageSubresourceLayers( - VideoCommon::SubresourceLayers subresource, VkImageAspectFlags aspect_mask) { - return VkImageSubresourceLayers{ - .aspectMask = aspect_mask, - .mipLevel = static_cast(subresource.base_level), - .baseArrayLayer = static_cast(subresource.base_layer), - .layerCount = static_cast(subresource.num_layers), - }; - } - - [[nodiscard]] VkOffset3D MakeOffset3D(VideoCommon::Offset3D offset3d) { - return VkOffset3D{ - .x = offset3d.x, - .y = offset3d.y, - .z = offset3d.z, - }; - } - - [[nodiscard]] VkExtent3D MakeExtent3D(VideoCommon::Extent3D extent3d) { - return VkExtent3D{ - .width = static_cast(extent3d.width), - .height = static_cast(extent3d.height), - .depth = static_cast(extent3d.depth), - }; - } - - [[nodiscard]] VkImageCopy MakeImageCopy(const VideoCommon::ImageCopy& copy, - VkImageAspectFlags aspect_mask) noexcept { - return VkImageCopy{ +[[nodiscard]] VkImageCopy MakeImageCopy(const VideoCommon::ImageCopy& copy, + VkImageAspectFlags aspect_mask) noexcept { + return VkImageCopy{ .srcSubresource = MakeImageSubresourceLayers(copy.src_subresource, aspect_mask), .srcOffset = MakeOffset3D(copy.src_offset), .dstSubresource = MakeImageSubresourceLayers(copy.dst_subresource, aspect_mask), @@ -364,58 +364,58 @@ namespace Vulkan { [[nodiscard]] VkBufferImageCopy MakeBufferImageCopy(const VideoCommon::ImageCopy& copy, bool is_src, VkImageAspectFlags aspect_mask) noexcept { -return VkBufferImageCopy{ -.bufferOffset = 0, -.bufferRowLength = 0, -.bufferImageHeight = 0, -.imageSubresource = MakeImageSubresourceLayers( - is_src ? copy.src_subresource : copy.dst_subresource, aspect_mask), -.imageOffset = MakeOffset3D(is_src ? copy.src_offset : copy.dst_offset), -.imageExtent = MakeExtent3D(copy.extent), -}; + return VkBufferImageCopy{ + .bufferOffset = 0, + .bufferRowLength = 0, + .bufferImageHeight = 0, + .imageSubresource = MakeImageSubresourceLayers( + is_src ? copy.src_subresource : copy.dst_subresource, aspect_mask), + .imageOffset = MakeOffset3D(is_src ? copy.src_offset : copy.dst_offset), + .imageExtent = MakeExtent3D(copy.extent), + }; } [[maybe_unused]] [[nodiscard]] boost::container::small_vector TransformBufferCopies(std::span copies, size_t buffer_offset) { boost::container::small_vector result(copies.size()); std::ranges::transform( - copies, result.begin(), [buffer_offset](const VideoCommon::BufferCopy& copy) { - return VkBufferCopy{ - .srcOffset = static_cast(copy.src_offset + buffer_offset), - .dstOffset = static_cast(copy.dst_offset), - .size = static_cast(copy.size), - }; - }); + copies, result.begin(), [buffer_offset](const VideoCommon::BufferCopy& copy) { + return VkBufferCopy{ + .srcOffset = static_cast(copy.src_offset + buffer_offset), + .dstOffset = static_cast(copy.dst_offset), + .size = static_cast(copy.size), + }; + }); return result; } [[nodiscard]] boost::container::small_vector TransformBufferImageCopies( - std::span copies, size_t buffer_offset, VkImageAspectFlags aspect_mask) { + std::span copies, size_t buffer_offset, VkImageAspectFlags aspect_mask) { struct Maker { VkBufferImageCopy operator()(const BufferImageCopy& copy) const { return VkBufferImageCopy{ - .bufferOffset = copy.buffer_offset + buffer_offset, - .bufferRowLength = copy.buffer_row_length, - .bufferImageHeight = copy.buffer_image_height, - .imageSubresource = - { - .aspectMask = aspect_mask, - .mipLevel = static_cast(copy.image_subresource.base_level), - .baseArrayLayer = static_cast(copy.image_subresource.base_layer), - .layerCount = static_cast(copy.image_subresource.num_layers), - }, - .imageOffset = - { - .x = copy.image_offset.x, - .y = copy.image_offset.y, - .z = copy.image_offset.z, - }, - .imageExtent = - { - .width = copy.image_extent.width, - .height = copy.image_extent.height, - .depth = copy.image_extent.depth, - }, + .bufferOffset = copy.buffer_offset + buffer_offset, + .bufferRowLength = copy.buffer_row_length, + .bufferImageHeight = copy.buffer_image_height, + .imageSubresource = + { + .aspectMask = aspect_mask, + .mipLevel = static_cast(copy.image_subresource.base_level), + .baseArrayLayer = static_cast(copy.image_subresource.base_layer), + .layerCount = static_cast(copy.image_subresource.num_layers), + }, + .imageOffset = + { + .x = copy.image_offset.x, + .y = copy.image_offset.y, + .z = copy.image_offset.z, + }, + .imageExtent = + { + .width = copy.image_extent.width, + .height = copy.image_extent.height, + .depth = copy.image_extent.depth, + }, }; } size_t buffer_offset; @@ -438,11 +438,11 @@ TransformBufferCopies(std::span copies, size_t bu [[nodiscard]] VkImageSubresourceRange MakeSubresourceRange(VkImageAspectFlags aspect_mask, const SubresourceRange& range) { return VkImageSubresourceRange{ - .aspectMask = aspect_mask, - .baseMipLevel = static_cast(range.base.level), - .levelCount = static_cast(range.extent.levels), - .baseArrayLayer = static_cast(range.base.layer), - .layerCount = static_cast(range.extent.layers), + .aspectMask = aspect_mask, + .baseMipLevel = static_cast(range.base.level), + .levelCount = static_cast(range.extent.levels), + .baseArrayLayer = static_cast(range.base.layer), + .layerCount = static_cast(range.extent.layers), }; } @@ -459,56 +459,56 @@ TransformBufferCopies(std::span copies, size_t bu [[nodiscard]] VkImageSubresourceLayers MakeSubresourceLayers(const ImageView* image_view) { return VkImageSubresourceLayers{ - .aspectMask = ImageAspectMask(image_view->format), - .mipLevel = static_cast(image_view->range.base.level), - .baseArrayLayer = static_cast(image_view->range.base.layer), - .layerCount = static_cast(image_view->range.extent.layers), + .aspectMask = ImageAspectMask(image_view->format), + .mipLevel = static_cast(image_view->range.base.level), + .baseArrayLayer = static_cast(image_view->range.base.layer), + .layerCount = static_cast(image_view->range.extent.layers), }; } [[nodiscard]] SwizzleSource ConvertGreenRed(SwizzleSource value) { switch (value) { - case SwizzleSource::G: - return SwizzleSource::R; - default: - return value; + case SwizzleSource::G: + return SwizzleSource::R; + default: + return value; } } [[nodiscard]] SwizzleSource SwapBlueRed(SwizzleSource value) { switch (value) { - case SwizzleSource::R: - return SwizzleSource::B; - case SwizzleSource::B: - return SwizzleSource::R; - default: - return value; + case SwizzleSource::R: + return SwizzleSource::B; + case SwizzleSource::B: + return SwizzleSource::R; + default: + return value; } } [[nodiscard]] SwizzleSource SwapGreenRed(SwizzleSource value) { switch (value) { - case SwizzleSource::R: - return SwizzleSource::G; - case SwizzleSource::G: - return SwizzleSource::R; - default: - return value; + case SwizzleSource::R: + return SwizzleSource::G; + case SwizzleSource::G: + return SwizzleSource::R; + default: + return value; } } [[nodiscard]] SwizzleSource SwapSpecial(SwizzleSource value) { switch (value) { - case SwizzleSource::A: - return SwizzleSource::R; - case SwizzleSource::R: - return SwizzleSource::A; - case SwizzleSource::G: - return SwizzleSource::B; - case SwizzleSource::B: - return SwizzleSource::G; - default: - return value; + case SwizzleSource::A: + return SwizzleSource::R; + case SwizzleSource::R: + return SwizzleSource::A; + case SwizzleSource::G: + return SwizzleSource::B; + case SwizzleSource::B: + return SwizzleSource::G; + default: + return value; } } @@ -516,46 +516,46 @@ void CopyBufferToImage(vk::CommandBuffer cmdbuf, VkBuffer src_buffer, VkImage im VkImageAspectFlags aspect_mask, bool is_initialized, std::span copies) { static constexpr VkAccessFlags WRITE_ACCESS_FLAGS = - VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; static constexpr VkAccessFlags READ_ACCESS_FLAGS = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; const VkImageMemoryBarrier read_barrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = WRITE_ACCESS_FLAGS, - .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .oldLayout = is_initialized ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_UNDEFINED, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = image, - .subresourceRange{ - .aspectMask = aspect_mask, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = WRITE_ACCESS_FLAGS, + .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .oldLayout = is_initialized ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_UNDEFINED, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = image, + .subresourceRange{ + .aspectMask = aspect_mask, + .baseMipLevel = 0, + .levelCount = VK_REMAINING_MIP_LEVELS, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, + }, }; const VkImageMemoryBarrier write_barrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = WRITE_ACCESS_FLAGS | READ_ACCESS_FLAGS, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = image, - .subresourceRange{ - .aspectMask = aspect_mask, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = WRITE_ACCESS_FLAGS | READ_ACCESS_FLAGS, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = image, + .subresourceRange{ + .aspectMask = aspect_mask, + .baseMipLevel = 0, + .levelCount = VK_REMAINING_MIP_LEVELS, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, + }, }; cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, read_barrier); @@ -569,34 +569,34 @@ void CopyBufferToImage(vk::CommandBuffer cmdbuf, VkBuffer src_buffer, VkImage im const VkImageSubresourceLayers& dst_layers, const VkImageSubresourceLayers& src_layers) { return VkImageBlit{ - .srcSubresource = src_layers, - .srcOffsets = - { - { - .x = src_region.start.x, - .y = src_region.start.y, - .z = 0, - }, - { - .x = src_region.end.x, - .y = src_region.end.y, - .z = 1, - }, - }, - .dstSubresource = dst_layers, - .dstOffsets = - { - { - .x = dst_region.start.x, - .y = dst_region.start.y, - .z = 0, - }, - { - .x = dst_region.end.x, - .y = dst_region.end.y, - .z = 1, - }, - }, + .srcSubresource = src_layers, + .srcOffsets = + { + { + .x = src_region.start.x, + .y = src_region.start.y, + .z = 0, + }, + { + .x = src_region.end.x, + .y = src_region.end.y, + .z = 1, + }, + }, + .dstSubresource = dst_layers, + .dstOffsets = + { + { + .x = dst_region.start.x, + .y = dst_region.start.y, + .z = 0, + }, + { + .x = dst_region.end.x, + .y = dst_region.end.y, + .z = 1, + }, + }, }; } @@ -605,53 +605,53 @@ void CopyBufferToImage(vk::CommandBuffer cmdbuf, VkBuffer src_buffer, VkImage im const VkImageSubresourceLayers& dst_layers, const VkImageSubresourceLayers& src_layers) { return VkImageResolve{ - .srcSubresource = src_layers, - .srcOffset = - { - .x = src_region.start.x, - .y = src_region.start.y, - .z = 0, - }, - .dstSubresource = dst_layers, - .dstOffset = - { - .x = dst_region.start.x, - .y = dst_region.start.y, - .z = 0, - }, - .extent = - { - .width = static_cast(dst_region.end.x - dst_region.start.x), - .height = static_cast(dst_region.end.y - dst_region.start.y), - .depth = 1, - }, + .srcSubresource = src_layers, + .srcOffset = + { + .x = src_region.start.x, + .y = src_region.start.y, + .z = 0, + }, + .dstSubresource = dst_layers, + .dstOffset = + { + .x = dst_region.start.x, + .y = dst_region.start.y, + .z = 0, + }, + .extent = + { + .width = static_cast(dst_region.end.x - dst_region.start.x), + .height = static_cast(dst_region.end.y - dst_region.start.y), + .depth = 1, + }, }; } void TryTransformSwizzleIfNeeded(PixelFormat format, std::array& swizzle, bool emulate_bgr565, bool emulate_a4b4g4r4) { switch (format) { - case PixelFormat::A1B5G5R5_UNORM: + case PixelFormat::A1B5G5R5_UNORM: + std::ranges::transform(swizzle, swizzle.begin(), SwapBlueRed); + break; + case PixelFormat::B5G6R5_UNORM: + if (emulate_bgr565) { std::ranges::transform(swizzle, swizzle.begin(), SwapBlueRed); - break; - case PixelFormat::B5G6R5_UNORM: - if (emulate_bgr565) { - std::ranges::transform(swizzle, swizzle.begin(), SwapBlueRed); - } - break; - case PixelFormat::A5B5G5R1_UNORM: - std::ranges::transform(swizzle, swizzle.begin(), SwapSpecial); - break; - case PixelFormat::G4R4_UNORM: - std::ranges::transform(swizzle, swizzle.begin(), SwapGreenRed); - break; - case PixelFormat::A4B4G4R4_UNORM: - if (emulate_a4b4g4r4) { - std::ranges::reverse(swizzle); - } - break; - default: - break; + } + break; + case PixelFormat::A5B5G5R1_UNORM: + std::ranges::transform(swizzle, swizzle.begin(), SwapSpecial); + break; + case PixelFormat::G4R4_UNORM: + std::ranges::transform(swizzle, swizzle.begin(), SwapGreenRed); + break; + case PixelFormat::A4B4G4R4_UNORM: + if (emulate_a4b4g4r4) { + std::ranges::reverse(swizzle); + } + break; + default: + break; } } @@ -670,33 +670,33 @@ struct RangedBarrierRange { VkImageSubresourceRange SubresourceRange(VkImageAspectFlags aspect_mask) const noexcept { return VkImageSubresourceRange{ - .aspectMask = aspect_mask, - .baseMipLevel = min_mip, - .levelCount = max_mip - min_mip, - .baseArrayLayer = min_layer, - .layerCount = max_layer - min_layer, + .aspectMask = aspect_mask, + .baseMipLevel = min_mip, + .levelCount = max_mip - min_mip, + .baseArrayLayer = min_layer, + .layerCount = max_layer - min_layer, }; } }; [[nodiscard]] VkFormat Format(Shader::ImageFormat format) { switch (format) { - case Shader::ImageFormat::Typeless: - break; - case Shader::ImageFormat::R8_SINT: - return VK_FORMAT_R8_SINT; - case Shader::ImageFormat::R8_UINT: - return VK_FORMAT_R8_UINT; - case Shader::ImageFormat::R16_UINT: - return VK_FORMAT_R16_UINT; - case Shader::ImageFormat::R16_SINT: - return VK_FORMAT_R16_SINT; - case Shader::ImageFormat::R32_UINT: - return VK_FORMAT_R32_UINT; - case Shader::ImageFormat::R32G32_UINT: - return VK_FORMAT_R32G32_UINT; - case Shader::ImageFormat::R32G32B32A32_UINT: - return VK_FORMAT_R32G32B32A32_UINT; + case Shader::ImageFormat::Typeless: + break; + case Shader::ImageFormat::R8_SINT: + return VK_FORMAT_R8_SINT; + case Shader::ImageFormat::R8_UINT: + return VK_FORMAT_R8_UINT; + case Shader::ImageFormat::R16_UINT: + return VK_FORMAT_R16_UINT; + case Shader::ImageFormat::R16_SINT: + return VK_FORMAT_R16_SINT; + case Shader::ImageFormat::R32_UINT: + return VK_FORMAT_R32_UINT; + case Shader::ImageFormat::R32G32_UINT: + return VK_FORMAT_R32G32_UINT; + case Shader::ImageFormat::R32G32B32A32_UINT: + return VK_FORMAT_R32G32B32A32_UINT; } ASSERT_MSG(false, "Invalid image format={}", format); return VK_FORMAT_R32_UINT; @@ -708,8 +708,8 @@ void BlitScale(Scheduler& scheduler, VkImage src_image, VkImage dst_image, const const bool is_2d = (info.type == ImageType::e2D); const auto resources = info.resources; const VkExtent2D extent{ - .width = info.size.width, - .height = info.size.height, + .width = info.size.width, + .height = info.size.height, }; // Depth and integer formats must use NEAREST filter for blits. const bool is_color{aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT}; @@ -718,119 +718,119 @@ void BlitScale(Scheduler& scheduler, VkImage src_image, VkImage dst_image, const scheduler.RequestOutsideRenderPassOperationContext(); scheduler.Record([dst_image, src_image, extent, resources, aspect_mask, resolution, is_2d, - vk_filter, up_scaling](vk::CommandBuffer cmdbuf) { + vk_filter, up_scaling](vk::CommandBuffer cmdbuf) { const VkOffset2D src_size{ - .x = static_cast(up_scaling ? extent.width : resolution.ScaleUp(extent.width)), - .y = static_cast(is_2d && up_scaling ? extent.height - : resolution.ScaleUp(extent.height)), + .x = static_cast(up_scaling ? extent.width : resolution.ScaleUp(extent.width)), + .y = static_cast(is_2d && up_scaling ? extent.height + : resolution.ScaleUp(extent.height)), }; const VkOffset2D dst_size{ - .x = static_cast(up_scaling ? resolution.ScaleUp(extent.width) : extent.width), - .y = static_cast(is_2d && up_scaling ? resolution.ScaleUp(extent.height) - : extent.height), + .x = static_cast(up_scaling ? resolution.ScaleUp(extent.width) : extent.width), + .y = static_cast(is_2d && up_scaling ? resolution.ScaleUp(extent.height) + : extent.height), }; boost::container::small_vector regions; regions.reserve(resources.levels); for (s32 level = 0; level < resources.levels; level++) { regions.push_back({ - .srcSubresource{ - .aspectMask = aspect_mask, - .mipLevel = static_cast(level), - .baseArrayLayer = 0, - .layerCount = static_cast(resources.layers), - }, - .srcOffsets{ - { - .x = 0, - .y = 0, - .z = 0, - }, - { - .x = std::max(1, src_size.x >> level), - .y = std::max(1, src_size.y >> level), - .z = 1, - }, - }, - .dstSubresource{ - .aspectMask = aspect_mask, - .mipLevel = static_cast(level), - .baseArrayLayer = 0, - .layerCount = static_cast(resources.layers), - }, - .dstOffsets{ - { - .x = 0, - .y = 0, - .z = 0, - }, - { - .x = std::max(1, dst_size.x >> level), - .y = std::max(1, dst_size.y >> level), - .z = 1, - }, - }, - }); + .srcSubresource{ + .aspectMask = aspect_mask, + .mipLevel = static_cast(level), + .baseArrayLayer = 0, + .layerCount = static_cast(resources.layers), + }, + .srcOffsets{ + { + .x = 0, + .y = 0, + .z = 0, + }, + { + .x = std::max(1, src_size.x >> level), + .y = std::max(1, src_size.y >> level), + .z = 1, + }, + }, + .dstSubresource{ + .aspectMask = aspect_mask, + .mipLevel = static_cast(level), + .baseArrayLayer = 0, + .layerCount = static_cast(resources.layers), + }, + .dstOffsets{ + { + .x = 0, + .y = 0, + .z = 0, + }, + { + .x = std::max(1, dst_size.x >> level), + .y = std::max(1, dst_size.y >> level), + .z = 1, + }, + }, + }); } const VkImageSubresourceRange subresource_range{ - .aspectMask = aspect_mask, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, + .aspectMask = aspect_mask, + .baseMipLevel = 0, + .levelCount = VK_REMAINING_MIP_LEVELS, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, }; const std::array read_barriers{ - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = src_image, - .subresourceRange = subresource_range, - }, - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, // Discard contents - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = dst_image, - .subresourceRange = subresource_range, - }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, + .oldLayout = VK_IMAGE_LAYOUT_GENERAL, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src_image, + .subresourceRange = subresource_range, + }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | + VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, // Discard contents + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = dst_image, + .subresourceRange = subresource_range, + }, }; const std::array write_barriers{ - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = 0, - .dstAccessMask = VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = src_image, - .subresourceRange = subresource_range, - }, - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = dst_image, - .subresourceRange = subresource_range, - }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = 0, + .dstAccessMask = VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src_image, + .subresourceRange = subresource_range, + }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = dst_image, + .subresourceRange = subresource_range, + }, }; cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, nullptr, nullptr, read_barriers); @@ -849,16 +849,16 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched RenderPassCache& render_pass_cache_, DescriptorPool& descriptor_pool, ComputePassDescriptorQueue& compute_pass_descriptor_queue) - : device{device_}, scheduler{scheduler_}, memory_allocator{memory_allocator_}, - staging_buffer_pool{staging_buffer_pool_}, blit_image_helper{blit_image_helper_}, - render_pass_cache{render_pass_cache_}, resolution{Settings::values.resolution_info} { + : device{device_}, scheduler{scheduler_}, memory_allocator{memory_allocator_}, + staging_buffer_pool{staging_buffer_pool_}, blit_image_helper{blit_image_helper_}, + render_pass_cache{render_pass_cache_}, resolution{Settings::values.resolution_info} { if (Settings::values.accelerate_astc.GetValue() == Settings::AstcDecodeMode::Gpu) { astc_decoder_pass.emplace(device, scheduler, descriptor_pool, staging_buffer_pool, compute_pass_descriptor_queue, memory_allocator); } if (device.IsStorageImageMultisampleSupported()) { msaa_copy_pass = std::make_unique( - device, scheduler, descriptor_pool, staging_buffer_pool, compute_pass_descriptor_queue); + device, scheduler, descriptor_pool, staging_buffer_pool, compute_pass_descriptor_queue); } if (!device.IsKhrImageFormatListSupported()) { return; @@ -872,7 +872,7 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched const auto view_format = static_cast(index_b); if (VideoCore::Surface::IsViewCompatible(image_format, view_format, false, true)) { const auto view_info = - MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, true, view_format); + MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, true, view_format); view_formats[index_a].push_back(view_info.format); } } @@ -897,7 +897,7 @@ void TextureCacheRuntime::FreeDeferredStagingBuffer(StagingBufferRef& ref) { bool TextureCacheRuntime::ShouldReinterpret(Image& dst, Image& src) { if (VideoCore::Surface::GetFormatType(dst.info.format) == - VideoCore::Surface::SurfaceType::DepthStencil && + VideoCore::Surface::SurfaceType::DepthStencil && !device.IsExtShaderStencilExportSupported()) { return true; } @@ -915,17 +915,17 @@ VkBuffer TextureCacheRuntime::GetTemporaryBuffer(size_t needed_size) { } const auto new_size = Common::NextPow2(needed_size); static constexpr VkBufferUsageFlags flags = - VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | - VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; + VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | + VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; const VkBufferCreateInfo temp_ci = { - .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .size = new_size, - .usage = flags, - .sharingMode = VK_SHARING_MODE_EXCLUSIVE, - .queueFamilyIndexCount = 0, - .pQueueFamilyIndices = nullptr, + .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, + .pNext = nullptr, + .flags = 0, + .size = new_size, + .usage = flags, + .sharingMode = VK_SHARING_MODE_EXCLUSIVE, + .queueFamilyIndexCount = 0, + .pQueueFamilyIndices = nullptr, }; buffers[level] = memory_allocator.CreateBuffer(temp_ci, MemoryUsage::DeviceLocal); return *buffers[level]; @@ -964,7 +964,7 @@ void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src, const VkImage src_image = src.Handle(); scheduler.RequestOutsideRenderPassOperationContext(); scheduler.Record([dst_image, src_image, copy_buffer, src_aspect_mask, dst_aspect_mask, - vk_in_copies, vk_out_copies](vk::CommandBuffer cmdbuf) { + vk_in_copies, vk_out_copies](vk::CommandBuffer cmdbuf) { RangedBarrierRange dst_range; RangedBarrierRange src_range; for (const VkBufferImageCopy& copy : vk_in_copies) { @@ -978,77 +978,77 @@ void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src, .pNext = nullptr, .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, - }; + }; static constexpr VkMemoryBarrier WRITE_BARRIER{ .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, .pNext = nullptr, .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, - }; + }; const std::array pre_barriers{ - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = src_image, - .subresourceRange = src_range.SubresourceRange(src_aspect_mask), - }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | + VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, + .oldLayout = VK_IMAGE_LAYOUT_GENERAL, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src_image, + .subresourceRange = src_range.SubresourceRange(src_aspect_mask), + }, }; const std::array middle_in_barrier{ - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = 0, - .dstAccessMask = 0, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = src_image, - .subresourceRange = src_range.SubresourceRange(src_aspect_mask), - }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = 0, + .dstAccessMask = 0, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src_image, + .subresourceRange = src_range.SubresourceRange(src_aspect_mask), + }, }; const std::array middle_out_barrier{ - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = dst_image, - .subresourceRange = dst_range.SubresourceRange(dst_aspect_mask), - }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | + VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_GENERAL, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = dst_image, + .subresourceRange = dst_range.SubresourceRange(dst_aspect_mask), + }, }; const std::array post_barriers{ - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | - VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | - VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = dst_image, - .subresourceRange = dst_range.SubresourceRange(dst_aspect_mask), - }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | + VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | + VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | + VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = dst_image, + .subresourceRange = dst_range.SubresourceRange(dst_aspect_mask), + }, }; cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, {}, {}, pre_barriers); @@ -1087,13 +1087,13 @@ void TextureCacheRuntime::BlitImage(Framebuffer* dst_framebuffer, ImageView& dst const auto format = src.format; const auto can_blit_depth_stencil = [this, format] { switch (format) { - case VideoCore::Surface::PixelFormat::D24_UNORM_S8_UINT: - case VideoCore::Surface::PixelFormat::S8_UINT_D24_UNORM: - return device.IsBlitDepth24Stencil8Supported(); - case VideoCore::Surface::PixelFormat::D32_FLOAT_S8_UINT: - return device.IsBlitDepth32Stencil8Supported(); - default: - UNREACHABLE(); + case VideoCore::Surface::PixelFormat::D24_UNORM_S8_UINT: + case VideoCore::Surface::PixelFormat::S8_UINT_D24_UNORM: + return device.IsBlitDepth24Stencil8Supported(); + case VideoCore::Surface::PixelFormat::D32_FLOAT_S8_UINT: + return device.IsBlitDepth32Stencil8Supported(); + default: + UNREACHABLE(); } }(); if (!can_blit_depth_stencil) { @@ -1113,69 +1113,69 @@ void TextureCacheRuntime::BlitImage(Framebuffer* dst_framebuffer, ImageView& dst const bool is_resolve = is_src_msaa && !is_dst_msaa; scheduler.RequestOutsideRenderPassOperationContext(); scheduler.Record([filter, dst_region, src_region, dst_image, src_image, dst_layers, src_layers, - aspect_mask, is_resolve](vk::CommandBuffer cmdbuf) { + aspect_mask, is_resolve](vk::CommandBuffer cmdbuf) { const std::array read_barriers{ - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = src_image, - .subresourceRange{ - .aspectMask = aspect_mask, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, - }, - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = dst_image, - .subresourceRange{ - .aspectMask = aspect_mask, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, - }, - }; - VkImageMemoryBarrier write_barrier{ + VkImageMemoryBarrier{ .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .pNext = nullptr, - .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | + .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, + .oldLayout = VK_IMAGE_LAYOUT_GENERAL, .newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src_image, + .subresourceRange{ + .aspectMask = aspect_mask, + .baseMipLevel = 0, + .levelCount = VK_REMAINING_MIP_LEVELS, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, + }, + }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | + VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_GENERAL, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .image = dst_image, .subresourceRange{ - .aspectMask = aspect_mask, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, + .aspectMask = aspect_mask, + .baseMipLevel = 0, + .levelCount = VK_REMAINING_MIP_LEVELS, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, }, + }, + }; + VkImageMemoryBarrier write_barrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | + VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = dst_image, + .subresourceRange{ + .aspectMask = aspect_mask, + .baseMipLevel = 0, + .levelCount = VK_REMAINING_MIP_LEVELS, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, + }, }; cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, nullptr, nullptr, read_barriers); @@ -1187,8 +1187,8 @@ void TextureCacheRuntime::BlitImage(Framebuffer* dst_framebuffer, ImageView& dst const bool is_linear = filter == Fermi2D::Filter::Bilinear; const VkFilter vk_filter = is_linear ? VK_FILTER_LINEAR : VK_FILTER_NEAREST; cmdbuf.BlitImage( - src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - MakeImageBlit(dst_region, src_region, dst_layers, src_layers), vk_filter); + src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + MakeImageBlit(dst_region, src_region, dst_layers, src_layers), vk_filter); } cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, write_barrier); @@ -1197,66 +1197,66 @@ void TextureCacheRuntime::BlitImage(Framebuffer* dst_framebuffer, ImageView& dst void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, ImageView& src_view) { switch (dst_view.format) { - case PixelFormat::R16_UNORM: - if (src_view.format == PixelFormat::D16_UNORM) { - return blit_image_helper.ConvertD16ToR16(dst, src_view); - } - break; - case PixelFormat::A8B8G8R8_SRGB: - if (src_view.format == PixelFormat::D32_FLOAT) { - return blit_image_helper.ConvertD32FToABGR8(dst, src_view); - } - break; - case PixelFormat::A8B8G8R8_UNORM: - if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) { - return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view); - } - if (src_view.format == PixelFormat::D24_UNORM_S8_UINT) { - return blit_image_helper.ConvertS8D24ToABGR8(dst, src_view); - } - if (src_view.format == PixelFormat::D32_FLOAT) { - return blit_image_helper.ConvertD32FToABGR8(dst, src_view); - } - break; - case PixelFormat::B8G8R8A8_SRGB: - if (src_view.format == PixelFormat::D32_FLOAT) { - return blit_image_helper.ConvertD32FToABGR8(dst, src_view); - } - break; - case PixelFormat::B8G8R8A8_UNORM: - if (src_view.format == PixelFormat::D32_FLOAT) { - return blit_image_helper.ConvertD32FToABGR8(dst, src_view); - } - break; - case PixelFormat::R32_FLOAT: - if (src_view.format == PixelFormat::D32_FLOAT) { - return blit_image_helper.ConvertD32ToR32(dst, src_view); - } - break; - case PixelFormat::D16_UNORM: - if (src_view.format == PixelFormat::R16_UNORM) { - return blit_image_helper.ConvertR16ToD16(dst, src_view); - } - break; - case PixelFormat::S8_UINT_D24_UNORM: - if (src_view.format == PixelFormat::A8B8G8R8_UNORM || - src_view.format == PixelFormat::B8G8R8A8_UNORM) { - return blit_image_helper.ConvertABGR8ToD24S8(dst, src_view); - } - break; - case PixelFormat::D32_FLOAT: - if (src_view.format == PixelFormat::A8B8G8R8_UNORM || - src_view.format == PixelFormat::B8G8R8A8_UNORM || - src_view.format == PixelFormat::A8B8G8R8_SRGB || - src_view.format == PixelFormat::B8G8R8A8_SRGB) { - return blit_image_helper.ConvertABGR8ToD32F(dst, src_view); - } - if (src_view.format == PixelFormat::R32_FLOAT) { - return blit_image_helper.ConvertR32ToD32(dst, src_view); - } - break; - default: - break; + case PixelFormat::R16_UNORM: + if (src_view.format == PixelFormat::D16_UNORM) { + return blit_image_helper.ConvertD16ToR16(dst, src_view); + } + break; + case PixelFormat::A8B8G8R8_SRGB: + if (src_view.format == PixelFormat::D32_FLOAT) { + return blit_image_helper.ConvertD32FToABGR8(dst, src_view); + } + break; + case PixelFormat::A8B8G8R8_UNORM: + if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) { + return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view); + } + if (src_view.format == PixelFormat::D24_UNORM_S8_UINT) { + return blit_image_helper.ConvertS8D24ToABGR8(dst, src_view); + } + if (src_view.format == PixelFormat::D32_FLOAT) { + return blit_image_helper.ConvertD32FToABGR8(dst, src_view); + } + break; + case PixelFormat::B8G8R8A8_SRGB: + if (src_view.format == PixelFormat::D32_FLOAT) { + return blit_image_helper.ConvertD32FToABGR8(dst, src_view); + } + break; + case PixelFormat::B8G8R8A8_UNORM: + if (src_view.format == PixelFormat::D32_FLOAT) { + return blit_image_helper.ConvertD32FToABGR8(dst, src_view); + } + break; + case PixelFormat::R32_FLOAT: + if (src_view.format == PixelFormat::D32_FLOAT) { + return blit_image_helper.ConvertD32ToR32(dst, src_view); + } + break; + case PixelFormat::D16_UNORM: + if (src_view.format == PixelFormat::R16_UNORM) { + return blit_image_helper.ConvertR16ToD16(dst, src_view); + } + break; + case PixelFormat::S8_UINT_D24_UNORM: + if (src_view.format == PixelFormat::A8B8G8R8_UNORM || + src_view.format == PixelFormat::B8G8R8A8_UNORM) { + return blit_image_helper.ConvertABGR8ToD24S8(dst, src_view); + } + break; + case PixelFormat::D32_FLOAT: + if (src_view.format == PixelFormat::A8B8G8R8_UNORM || + src_view.format == PixelFormat::B8G8R8A8_UNORM || + src_view.format == PixelFormat::A8B8G8R8_SRGB || + src_view.format == PixelFormat::B8G8R8A8_SRGB) { + return blit_image_helper.ConvertABGR8ToD32F(dst, src_view); + } + if (src_view.format == PixelFormat::R32_FLOAT) { + return blit_image_helper.ConvertR32ToD32(dst, src_view); + } + break; + default: + break; } UNIMPLEMENTED_MSG("Unimplemented format copy from {} to {}", src_view.format, dst_view.format); } @@ -1281,65 +1281,65 @@ void TextureCacheRuntime::CopyImage(Image& dst, Image& src, src_range.AddLayers(copy.srcSubresource); } const std::array pre_barriers{ - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = src_image, - .subresourceRange = src_range.SubresourceRange(aspect_mask), - }, - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = dst_image, - .subresourceRange = dst_range.SubresourceRange(aspect_mask), - }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | + VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, + .oldLayout = VK_IMAGE_LAYOUT_GENERAL, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src_image, + .subresourceRange = src_range.SubresourceRange(aspect_mask), + }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | + VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_GENERAL, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = dst_image, + .subresourceRange = dst_range.SubresourceRange(aspect_mask), + }, }; const std::array post_barriers{ - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = 0, - .dstAccessMask = 0, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = src_image, - .subresourceRange = src_range.SubresourceRange(aspect_mask), - }, - VkImageMemoryBarrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | - VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | - VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = dst_image, - .subresourceRange = dst_range.SubresourceRange(aspect_mask), - }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = 0, + .dstAccessMask = 0, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src_image, + .subresourceRange = src_range.SubresourceRange(aspect_mask), + }, + VkImageMemoryBarrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | + VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | + VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | + VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = dst_image, + .subresourceRange = dst_range.SubresourceRange(aspect_mask), + }, }; cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, {}, {}, pre_barriers); @@ -1375,24 +1375,24 @@ void TextureCacheRuntime::TickFrame() {} Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu_addr_, VAddr cpu_addr_) - : VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), scheduler{&runtime_.scheduler}, - runtime{&runtime_}, original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info, - runtime->ViewFormats(info.format))), - aspect_mask(ImageAspectMask(info.format)) { + : VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), scheduler{&runtime_.scheduler}, + runtime{&runtime_}, original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info, + runtime->ViewFormats(info.format))), + aspect_mask(ImageAspectMask(info.format)) { if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) { switch (Settings::values.accelerate_astc.GetValue()) { - case Settings::AstcDecodeMode::Gpu: - if (Settings::values.astc_recompression.GetValue() == + case Settings::AstcDecodeMode::Gpu: + if (Settings::values.astc_recompression.GetValue() == Settings::AstcRecompression::Uncompressed && - info.size.depth == 1) { - flags |= VideoCommon::ImageFlagBits::AcceleratedUpload; - } - break; - case Settings::AstcDecodeMode::CpuAsynchronous: - flags |= VideoCommon::ImageFlagBits::AsynchronousDecode; - break; - default: - break; + info.size.depth == 1) { + flags |= VideoCommon::ImageFlagBits::AcceleratedUpload; + } + break; + case Settings::AstcDecodeMode::CpuAsynchronous: + flags |= VideoCommon::ImageFlagBits::AsynchronousDecode; + break; + default: + break; } flags |= VideoCommon::ImageFlagBits::Converted; flags |= VideoCommon::ImageFlagBits::CostlyLoad; @@ -1408,11 +1408,11 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu storage_image_views.resize(info.resources.levels); if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported() && Settings::values.astc_recompression.GetValue() == - Settings::AstcRecompression::Uncompressed) { + Settings::AstcRecompression::Uncompressed) { const auto& device = runtime->device.GetLogical(); for (s32 level = 0; level < info.resources.levels; ++level) { storage_image_views[level] = - MakeStorageView(device, level, *original_image, VK_FORMAT_A8B8G8R8_UNORM_PACK32); + MakeStorageView(device, level, *original_image, VK_FORMAT_A8B8G8R8_UNORM_PACK32); } } } @@ -1435,7 +1435,7 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset, const VkImageAspectFlags vk_aspect_mask = aspect_mask; const bool is_initialized = std::exchange(initialized, true); scheduler->Record([src_buffer, vk_image, vk_aspect_mask, is_initialized, - vk_copies](vk::CommandBuffer cmdbuf) { + vk_copies](vk::CommandBuffer cmdbuf) { CopyBufferToImage(cmdbuf, src_buffer, vk_image, vk_aspect_mask, is_initialized, vk_copies); }); if (is_rescaled) { @@ -1450,10 +1450,10 @@ void Image::UploadMemory(const StagingBufferRef& map, std::span copies) { std::array buffer_handles{ - buffer, + buffer, }; std::array buffer_offsets{ - offset, + offset, }; DownloadMemory(buffer_handles, buffer_offsets, copies); } @@ -1466,32 +1466,32 @@ void Image::DownloadMemory(std::span buffers_span, std::span o } boost::container::small_vector buffers_vector{}; boost::container::small_vector, 8> - vk_copies; + vk_copies; for (size_t index = 0; index < buffers_span.size(); index++) { buffers_vector.emplace_back(buffers_span[index]); vk_copies.emplace_back( - TransformBufferImageCopies(copies, offsets_span[index], aspect_mask)); + TransformBufferImageCopies(copies, offsets_span[index], aspect_mask)); } scheduler->RequestOutsideRenderPassOperationContext(); scheduler->Record([buffers = std::move(buffers_vector), image = *original_image, - aspect_mask_ = aspect_mask, vk_copies](vk::CommandBuffer cmdbuf) { + aspect_mask_ = aspect_mask, vk_copies](vk::CommandBuffer cmdbuf) { const VkImageMemoryBarrier read_barrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, - .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = image, - .subresourceRange{ - .aspectMask = aspect_mask_, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, + .oldLayout = VK_IMAGE_LAYOUT_GENERAL, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = image, + .subresourceRange{ + .aspectMask = aspect_mask_, + .baseMipLevel = 0, + .levelCount = VK_REMAINING_MIP_LEVELS, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, + }, }; cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, read_barrier); @@ -1502,28 +1502,28 @@ void Image::DownloadMemory(std::span buffers_span, std::span o } const VkMemoryBarrier memory_write_barrier{ - .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, - .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, + .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, + .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, }; const VkImageMemoryBarrier image_write_barrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = 0, - .dstAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, - .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = image, - .subresourceRange{ - .aspectMask = aspect_mask_, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = 0, + .dstAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = image, + .subresourceRange{ + .aspectMask = aspect_mask_, + .baseMipLevel = 0, + .levelCount = VK_REMAINING_MIP_LEVELS, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, + }, }; cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, memory_write_barrier, nullptr, image_write_barrier); @@ -1535,27 +1535,27 @@ void Image::DownloadMemory(std::span buffers_span, std::span o void Image::DownloadMemory(const StagingBufferRef& map, std::span copies) { std::array buffers{ - map.buffer, + map.buffer, }; std::array offsets{ - static_cast(map.offset), + static_cast(map.offset), }; DownloadMemory(buffers, offsets, copies); } VkImageView Image::StorageImageView(s32 level) noexcept { -auto& view = storage_image_views[level]; -if (!view) { -const auto format_info = - MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format); -view = -MakeStorageView(runtime->device.GetLogical(), level, current_image, format_info.format); -} -return *view; + auto& view = storage_image_views[level]; + if (!view) { + const auto format_info = + MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format); + view = + MakeStorageView(runtime->device.GetLogical(), level, current_image, format_info.format); + } + return *view; } bool Image::IsRescaled() const noexcept { -return True(flags & ImageFlagBits::Rescaled); + return True(flags & ImageFlagBits::Rescaled); } bool Image::ScaleUp(bool ignore) { @@ -1634,7 +1634,7 @@ bool Image::BlitScaleHelper(bool scale_up) { const u32 scaled_height = is_2d ? resolution.ScaleUp(info.size.height) : info.size.height; std::unique_ptr& blit_view = scale_up ? scale_view : normal_view; std::unique_ptr& blit_framebuffer = - scale_up ? scale_framebuffer : normal_framebuffer; + scale_up ? scale_framebuffer : normal_framebuffer; if (!blit_view) { const auto view_info = ImageViewInfo(ImageViewType::e2D, info.format); blit_view = std::make_unique(*runtime, view_info, NULL_IMAGE_ID, *this); @@ -1645,23 +1645,23 @@ bool Image::BlitScaleHelper(bool scale_up) { const u32 dst_width = scale_up ? scaled_width : info.size.width; const u32 dst_height = scale_up ? scaled_height : info.size.height; const Region2D src_region{ - .start = {0, 0}, - .end = {static_cast(src_width), static_cast(src_height)}, + .start = {0, 0}, + .end = {static_cast(src_width), static_cast(src_height)}, }; const Region2D dst_region{ - .start = {0, 0}, - .end = {static_cast(dst_width), static_cast(dst_height)}, + .start = {0, 0}, + .end = {static_cast(dst_width), static_cast(dst_height)}, }; const VkExtent2D extent{ - .width = std::max(scaled_width, info.size.width), - .height = std::max(scaled_height, info.size.height), + .width = std::max(scaled_width, info.size.width), + .height = std::max(scaled_height, info.size.height), }; auto* view_ptr = blit_view.get(); if (aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT) { if (!blit_framebuffer) { blit_framebuffer = - std::make_unique(*runtime, view_ptr, nullptr, extent, scale_up); + std::make_unique(*runtime, view_ptr, nullptr, extent, scale_up); } const auto color_view = blit_view->Handle(Shader::TextureType::Color2D); @@ -1670,7 +1670,7 @@ bool Image::BlitScaleHelper(bool scale_up) { } else if (aspect_mask == (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { if (!blit_framebuffer) { blit_framebuffer = - std::make_unique(*runtime, nullptr, view_ptr, extent, scale_up); + std::make_unique(*runtime, nullptr, view_ptr, extent, scale_up); } runtime->blit_image_helper.BlitDepthStencil(blit_framebuffer.get(), blit_view->DepthView(), blit_view->StencilView(), dst_region, @@ -1692,7 +1692,7 @@ bool Image::NeedsScaleHelper() const { } static constexpr auto OPTIMAL_FORMAT = FormatType::Optimal; const auto vk_format = - MaxwellToVK::SurfaceFormat(device, OPTIMAL_FORMAT, false, info.format).format; + MaxwellToVK::SurfaceFormat(device, OPTIMAL_FORMAT, false, info.format).format; const auto blit_usage = VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT; const bool needs_blit_helper = !device.IsFormatSupported(vk_format, blit_usage, OPTIMAL_FORMAT); return needs_blit_helper; @@ -1700,17 +1700,17 @@ bool Image::NeedsScaleHelper() const { ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info, ImageId image_id_, Image& image) - : VideoCommon::ImageViewBase{info, image.info, image_id_, image.gpu_addr}, - device{&runtime.device}, image_handle{image.Handle()}, - samples(ConvertSampleCount(image.info.num_samples)) { + : VideoCommon::ImageViewBase{info, image.info, image_id_, image.gpu_addr}, + device{&runtime.device}, image_handle{image.Handle()}, + samples(ConvertSampleCount(image.info.num_samples)) { using Shader::TextureType; const VkImageAspectFlags aspect_mask = ImageViewAspectMask(info); std::array swizzle{ - SwizzleSource::R, - SwizzleSource::G, - SwizzleSource::B, - SwizzleSource::A, + SwizzleSource::R, + SwizzleSource::G, + SwizzleSource::B, + SwizzleSource::A, }; if (!info.IsRenderTarget()) { swizzle = info.Swizzle(); @@ -1722,24 +1722,24 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI } const auto format_info = MaxwellToVK::SurfaceFormat(*device, FormatType::Optimal, true, format); const VkImageViewUsageCreateInfo image_view_usage{ - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, - .pNext = nullptr, - .usage = ImageUsageFlags(format_info, format), + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, + .pNext = nullptr, + .usage = ImageUsageFlags(format_info, format), }; const VkImageViewCreateInfo create_info{ - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - .pNext = &image_view_usage, - .flags = 0, - .image = image.Handle(), - .viewType = VkImageViewType{}, - .format = format_info.format, - .components{ - .r = ComponentSwizzle(swizzle[0]), - .g = ComponentSwizzle(swizzle[1]), - .b = ComponentSwizzle(swizzle[2]), - .a = ComponentSwizzle(swizzle[3]), - }, - .subresourceRange = MakeSubresourceRange(aspect_mask, info.range), + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + .pNext = &image_view_usage, + .flags = 0, + .image = image.Handle(), + .viewType = VkImageViewType{}, + .format = format_info.format, + .components{ + .r = ComponentSwizzle(swizzle[0]), + .g = ComponentSwizzle(swizzle[1]), + .b = ComponentSwizzle(swizzle[2]), + .a = ComponentSwizzle(swizzle[3]), + }, + .subresourceRange = MakeSubresourceRange(aspect_mask, info.range), }; const auto create = [&](TextureType tex_type, std::optional num_layers) { VkImageViewCreateInfo ci{create_info}; @@ -1754,47 +1754,47 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI image_views[static_cast(tex_type)] = std::move(handle); }; switch (info.type) { - case VideoCommon::ImageViewType::e1D: - case VideoCommon::ImageViewType::e1DArray: - create(TextureType::Color1D, 1); - create(TextureType::ColorArray1D, std::nullopt); - render_target = Handle(TextureType::ColorArray1D); - break; - case VideoCommon::ImageViewType::e2D: - case VideoCommon::ImageViewType::e2DArray: - case VideoCommon::ImageViewType::Rect: - create(TextureType::Color2D, 1); - create(TextureType::ColorArray2D, std::nullopt); - render_target = Handle(Shader::TextureType::ColorArray2D); - break; - case VideoCommon::ImageViewType::e3D: - create(TextureType::Color3D, std::nullopt); - render_target = Handle(Shader::TextureType::Color3D); - break; - case VideoCommon::ImageViewType::Cube: - case VideoCommon::ImageViewType::CubeArray: - create(TextureType::ColorCube, 6); - create(TextureType::ColorArrayCube, std::nullopt); - break; - case VideoCommon::ImageViewType::Buffer: - ASSERT(false); - break; + case VideoCommon::ImageViewType::e1D: + case VideoCommon::ImageViewType::e1DArray: + create(TextureType::Color1D, 1); + create(TextureType::ColorArray1D, std::nullopt); + render_target = Handle(TextureType::ColorArray1D); + break; + case VideoCommon::ImageViewType::e2D: + case VideoCommon::ImageViewType::e2DArray: + case VideoCommon::ImageViewType::Rect: + create(TextureType::Color2D, 1); + create(TextureType::ColorArray2D, std::nullopt); + render_target = Handle(Shader::TextureType::ColorArray2D); + break; + case VideoCommon::ImageViewType::e3D: + create(TextureType::Color3D, std::nullopt); + render_target = Handle(Shader::TextureType::Color3D); + break; + case VideoCommon::ImageViewType::Cube: + case VideoCommon::ImageViewType::CubeArray: + create(TextureType::ColorCube, 6); + create(TextureType::ColorArrayCube, std::nullopt); + break; + case VideoCommon::ImageViewType::Buffer: + ASSERT(false); + break; } } ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info, ImageId image_id_, Image& image, const SlotVector& slot_imgs) - : ImageView{runtime, info, image_id_, image} { + : ImageView{runtime, info, image_id_, image} { slot_images = &slot_imgs; } ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::ImageInfo& info, const VideoCommon::ImageViewInfo& view_info, GPUVAddr gpu_addr_) - : VideoCommon::ImageViewBase{info, view_info, gpu_addr_}, - buffer_size{VideoCommon::CalculateGuestSizeInBytes(info)} {} + : VideoCommon::ImageViewBase{info, view_info, gpu_addr_}, + buffer_size{VideoCommon::CalculateGuestSizeInBytes(info)} {} ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::NullImageViewParams& params) - : VideoCommon::ImageViewBase{params}, device{&runtime.device} { + : VideoCommon::ImageViewBase{params}, device{&runtime.device} { if (device->HasNullDescriptor()) { return; } @@ -1870,30 +1870,30 @@ VkImageView ImageView::StorageView(Shader::TextureType texture_type, } bool ImageView::IsRescaled() const noexcept { -if (!slot_images) { -return false; -} -const auto& slots = *slot_images; -const auto& src_image = slots[image_id]; -return src_image.IsRescaled(); + if (!slot_images) { + return false; + } + const auto& slots = *slot_images; + const auto& src_image = slots[image_id]; + return src_image.IsRescaled(); } vk::ImageView ImageView::MakeView(VkFormat vk_format, VkImageAspectFlags aspect_mask) { return device->GetLogical().CreateImageView({ - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .image = image_handle, - .viewType = ImageViewType(type), - .format = vk_format, - .components{ - .r = VK_COMPONENT_SWIZZLE_IDENTITY, - .g = VK_COMPONENT_SWIZZLE_IDENTITY, - .b = VK_COMPONENT_SWIZZLE_IDENTITY, - .a = VK_COMPONENT_SWIZZLE_IDENTITY, - }, - .subresourceRange = MakeSubresourceRange(aspect_mask, range), - }); + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + .pNext = nullptr, + .flags = 0, + .image = image_handle, + .viewType = ImageViewType(type), + .format = vk_format, + .components{ + .r = VK_COMPONENT_SWIZZLE_IDENTITY, + .g = VK_COMPONENT_SWIZZLE_IDENTITY, + .b = VK_COMPONENT_SWIZZLE_IDENTITY, + .a = VK_COMPONENT_SWIZZLE_IDENTITY, + }, + .subresourceRange = MakeSubresourceRange(aspect_mask, range), + }); } Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& tsc) { @@ -1902,20 +1902,20 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t const auto color = tsc.BorderColor(); const VkSamplerCustomBorderColorCreateInfoEXT border_ci{ - .sType = VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT, - .pNext = nullptr, - // TODO: Make use of std::bit_cast once libc++ supports it. - .customBorderColor = Common::BitCast(color), - .format = VK_FORMAT_UNDEFINED, + .sType = VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT, + .pNext = nullptr, + // TODO: Make use of std::bit_cast once libc++ supports it. + .customBorderColor = Common::BitCast(color), + .format = VK_FORMAT_UNDEFINED, }; const void* pnext = nullptr; if (arbitrary_borders) { pnext = &border_ci; } const VkSamplerReductionModeCreateInfoEXT reduction_ci{ - .sType = VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT, - .pNext = pnext, - .reductionMode = MaxwellToVK::SamplerReduction(tsc.reduction_filter), + .sType = VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT, + .pNext = pnext, + .reductionMode = MaxwellToVK::SamplerReduction(tsc.reduction_filter), }; if (runtime.device.IsExtSamplerFilterMinmaxSupported()) { pnext = &reduction_ci; @@ -1927,25 +1927,25 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t const auto create_sampler = [&](const f32 anisotropy) { return device.GetLogical().CreateSampler(VkSamplerCreateInfo{ - .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, - .pNext = pnext, - .flags = 0, - .magFilter = MaxwellToVK::Sampler::Filter(tsc.mag_filter), - .minFilter = MaxwellToVK::Sampler::Filter(tsc.min_filter), - .mipmapMode = MaxwellToVK::Sampler::MipmapMode(tsc.mipmap_filter), - .addressModeU = MaxwellToVK::Sampler::WrapMode(device, tsc.wrap_u, tsc.mag_filter), - .addressModeV = MaxwellToVK::Sampler::WrapMode(device, tsc.wrap_v, tsc.mag_filter), - .addressModeW = MaxwellToVK::Sampler::WrapMode(device, tsc.wrap_p, tsc.mag_filter), - .mipLodBias = tsc.LodBias(), - .anisotropyEnable = static_cast(anisotropy > 1.0f ? VK_TRUE : VK_FALSE), - .maxAnisotropy = anisotropy, - .compareEnable = tsc.depth_compare_enabled, - .compareOp = MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func), - .minLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.0f : tsc.MinLod(), - .maxLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.25f : tsc.MaxLod(), - .borderColor = + .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, + .pNext = pnext, + .flags = 0, + .magFilter = MaxwellToVK::Sampler::Filter(tsc.mag_filter), + .minFilter = MaxwellToVK::Sampler::Filter(tsc.min_filter), + .mipmapMode = MaxwellToVK::Sampler::MipmapMode(tsc.mipmap_filter), + .addressModeU = MaxwellToVK::Sampler::WrapMode(device, tsc.wrap_u, tsc.mag_filter), + .addressModeV = MaxwellToVK::Sampler::WrapMode(device, tsc.wrap_v, tsc.mag_filter), + .addressModeW = MaxwellToVK::Sampler::WrapMode(device, tsc.wrap_p, tsc.mag_filter), + .mipLodBias = tsc.LodBias(), + .anisotropyEnable = static_cast(anisotropy > 1.0f ? VK_TRUE : VK_FALSE), + .maxAnisotropy = anisotropy, + .compareEnable = tsc.depth_compare_enabled, + .compareOp = MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func), + .minLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.0f : tsc.MinLod(), + .maxLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.25f : tsc.MaxLod(), + .borderColor = arbitrary_borders ? VK_BORDER_COLOR_FLOAT_CUSTOM_EXT : ConvertBorderColor(color), - .unnormalizedCoordinates = VK_FALSE, + .unnormalizedCoordinates = VK_FALSE, }); }; @@ -1959,10 +1959,10 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t Framebuffer::Framebuffer(TextureCacheRuntime& runtime, std::span color_buffers, ImageView* depth_buffer, const VideoCommon::RenderTargets& key) - : render_area{VkExtent2D{ - .width = key.size.width, - .height = key.size.height, -}} { + : render_area{VkExtent2D{ + .width = key.size.width, + .height = key.size.height, + }} { CreateFramebuffer(runtime, color_buffers, depth_buffer, key.is_rescaled); if (runtime.device.HasDebuggingToolAttached()) { framebuffer.SetObjectNameEXT(VideoCommon::Name(key).c_str()); @@ -1971,7 +1971,7 @@ Framebuffer::Framebuffer(TextureCacheRuntime& runtime, std::span color_buffers{color_buffer}; CreateFramebuffer(runtime, color_buffers, depth_buffer, is_rescaled_); } @@ -2036,21 +2036,21 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime, num_color_buffers = static_cast(num_colors); framebuffer = runtime.device.GetLogical().CreateFramebuffer({ - .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .renderPass = renderpass, - .attachmentCount = static_cast(attachments.size()), - .pAttachments = attachments.data(), - .width = render_area.width, - .height = render_area.height, - .layers = static_cast(std::max(num_layers, 1)), - }); + .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, + .pNext = nullptr, + .flags = 0, + .renderPass = renderpass, + .attachmentCount = static_cast(attachments.size()), + .pAttachments = attachments.data(), + .width = render_area.width, + .height = render_area.height, + .layers = static_cast(std::max(num_layers, 1)), + }); } void TextureCacheRuntime::AccelerateImageUpload( - Image& image, const StagingBufferRef& map, - std::span swizzles) { + Image& image, const StagingBufferRef& map, + std::span swizzles) { if (IsPixelFormatASTC(image.info.format)) { return astc_decoder_pass->Assemble(image, map, swizzles); } @@ -2060,22 +2060,22 @@ void TextureCacheRuntime::AccelerateImageUpload( void TextureCacheRuntime::TransitionImageLayout(Image& image) { if (!image.ExchangeInitialization()) { VkImageMemoryBarrier barrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_NONE, - .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, - .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = image.Handle(), - .subresourceRange{ - .aspectMask = image.AspectMask(), - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_NONE, + .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, + .newLayout = VK_IMAGE_LAYOUT_GENERAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = image.Handle(), + .subresourceRange{ + .aspectMask = image.AspectMask(), + .baseMipLevel = 0, + .levelCount = VK_REMAINING_MIP_LEVELS, + .baseArrayLayer = 0, + .layerCount = VK_REMAINING_ARRAY_LAYERS, + }, }; scheduler.RequestOutsideRenderPassOperationContext(); scheduler.Record([barrier](vk::CommandBuffer cmdbuf) { diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp index 282bb04ae5..54d2b95f29 100644 --- a/src/video_core/shader_environment.cpp +++ b/src/video_core/shader_environment.cpp @@ -398,8 +398,8 @@ u32 GraphicsEnvironment::ReadViewportTransformState() { ComputeEnvironment::ComputeEnvironment(Tegra::Engines::KeplerCompute& kepler_compute_, Tegra::MemoryManager& gpu_memory_, GPUVAddr program_base_, u32 start_address_) - : GenericEnvironment{gpu_memory_, program_base_, start_address_}, kepler_compute{ - &kepler_compute_} { + : GenericEnvironment{gpu_memory_, program_base_, start_address_}, + kepler_compute{&kepler_compute_} { const auto& qmd{kepler_compute->launch_description}; stage = Shader::Stage::Compute; local_memory_size = qmd.local_pos_alloc + qmd.local_crs_alloc; diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h index 757f3c8afb..fd14decd9f 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.h +++ b/src/video_core/vulkan_common/vulkan_wrapper.h @@ -625,8 +625,8 @@ class Image { public: explicit Image(VkImage handle_, VkDevice owner_, VmaAllocator allocator_, VmaAllocation allocation_, const DeviceDispatch& dld_) noexcept - : handle{handle_}, owner{owner_}, allocator{allocator_}, - allocation{allocation_}, dld{&dld_} {} + : handle{handle_}, owner{owner_}, allocator{allocator_}, allocation{allocation_}, + dld{&dld_} {} Image() = default; Image(const Image&) = delete; @@ -680,8 +680,8 @@ public: explicit Buffer(VkBuffer handle_, VkDevice owner_, VmaAllocator allocator_, VmaAllocation allocation_, std::span mapped_, bool is_coherent_, const DeviceDispatch& dld_) noexcept - : handle{handle_}, owner{owner_}, allocator{allocator_}, - allocation{allocation_}, mapped{mapped_}, is_coherent{is_coherent_}, dld{&dld_} {} + : handle{handle_}, owner{owner_}, allocator{allocator_}, allocation{allocation_}, + mapped{mapped_}, is_coherent{is_coherent_}, dld{&dld_} {} Buffer() = default; Buffer(const Buffer&) = delete; @@ -689,8 +689,8 @@ public: Buffer(Buffer&& rhs) noexcept : handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, allocator{rhs.allocator}, - allocation{rhs.allocation}, mapped{rhs.mapped}, - is_coherent{rhs.is_coherent}, dld{rhs.dld} {} + allocation{rhs.allocation}, mapped{rhs.mapped}, is_coherent{rhs.is_coherent}, + dld{rhs.dld} {} Buffer& operator=(Buffer&& rhs) noexcept { Release();