diff options
| author | JosJuice <josjuice@gmail.com> | 2026-04-18 21:02:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-18 21:02:30 +0200 |
| commit | 74bb80544e8776750ee918fd4574a5b8eefd9774 (patch) | |
| tree | 5ffec7ba44c2ef6f51e5f48fd4ba95c6fed51d09 /Source/Core/VideoCommon | |
| parent | 5f2641ba4df22eeaa4357981f9a0e7fc54e43f3a (diff) | |
| parent | 95dec132030e72b74da6bc46966e4fe5e4e239c0 (diff) | |
Merge pull request #14565 from SuperSamus/cpp-argument-move-reference
Improve usage of std::move and const references parameters
Diffstat (limited to 'Source/Core/VideoCommon')
20 files changed, 69 insertions, 61 deletions
diff --git a/Source/Core/VideoCommon/Assets/CustomAsset.cpp b/Source/Core/VideoCommon/Assets/CustomAsset.cpp index 7e2e817d15..c01fb3b689 100644 --- a/Source/Core/VideoCommon/Assets/CustomAsset.cpp +++ b/Source/Core/VideoCommon/Assets/CustomAsset.cpp @@ -8,8 +8,8 @@ namespace VideoCommon { CustomAsset::CustomAsset(std::shared_ptr<CustomAssetLibrary> library, - const CustomAssetLibrary::AssetID& asset_id, u64 asset_handle) - : m_owning_library(std::move(library)), m_asset_id(asset_id), m_handle(asset_handle) + CustomAssetLibrary::AssetID asset_id, u64 asset_handle) + : m_owning_library(std::move(library)), m_asset_id(std::move(asset_id)), m_handle(asset_handle) { } diff --git a/Source/Core/VideoCommon/Assets/CustomAsset.h b/Source/Core/VideoCommon/Assets/CustomAsset.h index cdf5f14e70..6fe25a7fcf 100644 --- a/Source/Core/VideoCommon/Assets/CustomAsset.h +++ b/Source/Core/VideoCommon/Assets/CustomAsset.h @@ -20,8 +20,8 @@ public: using ClockType = std::chrono::steady_clock; using TimeType = ClockType::time_point; - CustomAsset(std::shared_ptr<CustomAssetLibrary> library, - const CustomAssetLibrary::AssetID& asset_id, u64 session_id); + CustomAsset(std::shared_ptr<CustomAssetLibrary> library, CustomAssetLibrary::AssetID asset_id, + u64 session_id); virtual ~CustomAsset() = default; CustomAsset(const CustomAsset&) = delete; CustomAsset(CustomAsset&&) = delete; diff --git a/Source/Core/VideoCommon/Assets/ShaderAsset.cpp b/Source/Core/VideoCommon/Assets/ShaderAsset.cpp index 04a9139212..d6ec53db6d 100644 --- a/Source/Core/VideoCommon/Assets/ShaderAsset.cpp +++ b/Source/Core/VideoCommon/Assets/ShaderAsset.cpp @@ -116,7 +116,7 @@ static bool ParseShaderValue(const CustomAssetLibrary::AssetID& asset_id, ShaderProperty::RGB rgb; if (!ParseNumeric<float, 3>(asset_id, json_value, code_name, &rgb.value)) return false; - *value = std::move(rgb); + *value = rgb; return true; } else if (type == "rgba") @@ -124,7 +124,7 @@ static bool ParseShaderValue(const CustomAssetLibrary::AssetID& asset_id, ShaderProperty::RGBA rgba; if (!ParseNumeric<float, 4>(asset_id, json_value, code_name, &rgba.value)) return false; - *value = std::move(rgba); + *value = rgba; return true; } else if (type == "bool") diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp index bb09a84328..df8e07469f 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp @@ -9,8 +9,7 @@ #include "Common/CommonTypes.h" #include "VideoCommon/Assets/CustomAssetLibrary.h" -void CustomPipeline::UpdatePixelData(std::shared_ptr<VideoCommon::CustomAssetLibrary>, - std::span<const u32>, +void CustomPipeline::UpdatePixelData(const VideoCommon::CustomAssetLibrary*, std::span<const u32>, const VideoCommon::CustomAssetLibrary::AssetID&) { } diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.h index 3aa7b6641c..a05a28ea16 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.h @@ -11,7 +11,7 @@ struct CustomPipeline { - void UpdatePixelData(std::shared_ptr<VideoCommon::CustomAssetLibrary> library, + void UpdatePixelData(const VideoCommon::CustomAssetLibrary* library, std::span<const u32> texture_units, const VideoCommon::CustomAssetLibrary::AssetID& material_to_load); }; diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomShaderCache.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomShaderCache.cpp index 54b0d786f2..91d4082348 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomShaderCache.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomShaderCache.cpp @@ -3,6 +3,8 @@ #include "VideoCommon/GraphicsModSystem/Runtime/CustomShaderCache.h" +#include <utility> + #include "VideoCommon/AbstractGfx.h" #include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoEvents.h" @@ -100,11 +102,11 @@ void CustomShaderCache::AsyncCreatePipeline(const VideoCommon::GXPipelineUid& ui class PipelineWorkItem final : public VideoCommon::AsyncShaderCompiler::WorkItem { public: - PipelineWorkItem(CustomShaderCache* shader_cache, const VideoCommon::GXPipelineUid& uid, - const CustomShaderInstance& custom_shaders, PipelineIterator iterator, - const AbstractPipelineConfig& pipeline_config) - : m_shader_cache(shader_cache), m_uid(uid), m_iterator(iterator), m_config(pipeline_config), - m_custom_shaders(custom_shaders) + PipelineWorkItem(CustomShaderCache* shader_cache, VideoCommon::GXPipelineUid uid, + CustomShaderInstance custom_shaders, PipelineIterator iterator, + AbstractPipelineConfig pipeline_config) + : m_shader_cache(shader_cache), m_uid(std::move(uid)), m_iterator(iterator), + m_config(std::move(pipeline_config)), m_custom_shaders(std::move(custom_shaders)) { SetStagesReady(); } @@ -184,11 +186,11 @@ void CustomShaderCache::AsyncCreatePipeline(const VideoCommon::GXUberPipelineUid class PipelineWorkItem final : public VideoCommon::AsyncShaderCompiler::WorkItem { public: - PipelineWorkItem(CustomShaderCache* shader_cache, const VideoCommon::GXUberPipelineUid& uid, - const CustomShaderInstance& custom_shaders, UberPipelineIterator iterator, - const AbstractPipelineConfig& pipeline_config) - : m_shader_cache(shader_cache), m_uid(uid), m_iterator(iterator), m_config(pipeline_config), - m_custom_shaders(custom_shaders) + PipelineWorkItem(CustomShaderCache* shader_cache, VideoCommon::GXUberPipelineUid uid, + CustomShaderInstance custom_shaders, UberPipelineIterator iterator, + AbstractPipelineConfig pipeline_config) + : m_shader_cache(shader_cache), m_uid(std::move(uid)), m_iterator(iterator), + m_config(std::move(pipeline_config)), m_custom_shaders(std::move(custom_shaders)) { SetStagesReady(); } @@ -281,8 +283,9 @@ void CustomShaderCache::QueuePixelShaderCompile(const PixelShaderUid& uid, { public: PixelShaderWorkItem(CustomShaderCache* shader_cache, const PixelShaderUid& uid, - const CustomShaderInstance& custom_shaders, PixelShaderIterator iter) - : m_shader_cache(shader_cache), m_uid(uid), m_custom_shaders(custom_shaders), m_iter(iter) + CustomShaderInstance custom_shaders, PixelShaderIterator iter) + : m_shader_cache(shader_cache), m_uid(uid), m_custom_shaders(std::move(custom_shaders)), + m_iter(iter) { } @@ -319,8 +322,9 @@ void CustomShaderCache::QueuePixelShaderCompile(const UberShader::PixelShaderUid { public: PixelShaderWorkItem(CustomShaderCache* shader_cache, const UberShader::PixelShaderUid& uid, - const CustomShaderInstance& custom_shaders, UberPixelShaderIterator iter) - : m_shader_cache(shader_cache), m_uid(uid), m_custom_shaders(custom_shaders), m_iter(iter) + CustomShaderInstance custom_shaders, UberPixelShaderIterator iter) + : m_shader_cache(shader_cache), m_uid(uid), m_custom_shaders(std::move(custom_shaders)), + m_iter(iter) { } diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp index 5f9cf48d52..c49b655804 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp @@ -247,23 +247,22 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config) } } + const auto create_action = + [filesystem_library = std::move(filesystem_library)]( + const std::string_view& action_name, const picojson::value& json_data, + GraphicsModConfig mod_config) -> std::unique_ptr<GraphicsModAction> { + auto action = GraphicsModActionFactory::Create(action_name, json_data, filesystem_library); + if (action == nullptr) + { + return nullptr; + } + return std::make_unique<DecoratedAction>(std::move(action), std::move(mod_config)); + }; + for (const auto& mod : mods) { for (const GraphicsModFeatureConfig& feature : mod.m_features) { - const auto create_action = - [filesystem_library](const std::string_view& action_name, - const picojson::value& json_data, - GraphicsModConfig mod_config) -> std::unique_ptr<GraphicsModAction> { - auto action = - GraphicsModActionFactory::Create(action_name, json_data, std::move(filesystem_library)); - if (action == nullptr) - { - return nullptr; - } - return std::make_unique<DecoratedAction>(std::move(action), std::move(mod_config)); - }; - const auto internal_group = fmt::format("{}.{}", mod.m_title, feature.m_group); const auto add_target = [&](const GraphicsTargetConfig& target) { diff --git a/Source/Core/VideoCommon/NetPlayGolfUI.cpp b/Source/Core/VideoCommon/NetPlayGolfUI.cpp index d8ada720ad..87b866b348 100644 --- a/Source/Core/VideoCommon/NetPlayGolfUI.cpp +++ b/Source/Core/VideoCommon/NetPlayGolfUI.cpp @@ -3,6 +3,8 @@ #include "VideoCommon/NetPlayGolfUI.h" +#include <utility> + #include <fmt/format.h> #include <imgui.h> @@ -13,8 +15,8 @@ constexpr float DEFAULT_WINDOW_HEIGHT = 45.0f; std::unique_ptr<NetPlayGolfUI> g_netplay_golf_ui; -NetPlayGolfUI::NetPlayGolfUI(std::shared_ptr<NetPlay::NetPlayClient> netplay_client) - : m_netplay_client{netplay_client} +NetPlayGolfUI::NetPlayGolfUI(std::weak_ptr<NetPlay::NetPlayClient> netplay_client) + : m_netplay_client{std::move(netplay_client)} { } diff --git a/Source/Core/VideoCommon/NetPlayGolfUI.h b/Source/Core/VideoCommon/NetPlayGolfUI.h index d8d69ffe66..fc815a75e9 100644 --- a/Source/Core/VideoCommon/NetPlayGolfUI.h +++ b/Source/Core/VideoCommon/NetPlayGolfUI.h @@ -13,7 +13,7 @@ class NetPlayClient; class NetPlayGolfUI { public: - explicit NetPlayGolfUI(std::shared_ptr<NetPlay::NetPlayClient> netplay_client); + explicit NetPlayGolfUI(std::weak_ptr<NetPlay::NetPlayClient> netplay_client); ~NetPlayGolfUI(); void Display(); diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 6f42879c34..8ab5463d3d 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -142,14 +142,14 @@ void AddTypedMessage(MessageType type, std::string message, u32 ms, u32 argb, for (auto it = range.first; it != range.second; ++it) it->second.should_discard = true; - s_messages.emplace(type, Message(std::move(message), ms, argb, std::move(icon))); + s_messages.emplace(type, Message(std::move(message), ms, argb, icon)); } void AddMessage(std::string message, u32 ms, u32 argb, const VideoCommon::CustomTextureData::ArraySlice::Level* icon) { std::lock_guard lock{s_messages_mutex}; - s_messages.emplace(MessageType::Typeless, Message(std::move(message), ms, argb, std::move(icon))); + s_messages.emplace(MessageType::Typeless, Message(std::move(message), ms, argb, icon)); } void DrawMessages() diff --git a/Source/Core/VideoCommon/PerformanceTracker.cpp b/Source/Core/VideoCommon/PerformanceTracker.cpp index 725d6b26e3..3d519865be 100644 --- a/Source/Core/VideoCommon/PerformanceTracker.cpp +++ b/Source/Core/VideoCommon/PerformanceTracker.cpp @@ -6,6 +6,7 @@ #include <algorithm> #include <cmath> #include <iomanip> +#include <utility> #include <implot.h> @@ -18,9 +19,9 @@ static constexpr double SAMPLE_RC_RATIO = 0.25; static constexpr u64 MAX_DT_QUEUE_SIZE = 1UL << 12; static constexpr u64 MAX_QUALITY_GRAPH_SIZE = 1UL << 8; -PerformanceTracker::PerformanceTracker(const std::optional<std::string> log_name, +PerformanceTracker::PerformanceTracker(std::optional<std::string> log_name, const std::optional<DT> sample_window_duration) - : m_log_name{log_name}, m_sample_window_duration{sample_window_duration} + : m_log_name{std::move(log_name)}, m_sample_window_duration{sample_window_duration} { Reset(); } diff --git a/Source/Core/VideoCommon/PerformanceTracker.h b/Source/Core/VideoCommon/PerformanceTracker.h index 358de676b4..e210a8497c 100644 --- a/Source/Core/VideoCommon/PerformanceTracker.h +++ b/Source/Core/VideoCommon/PerformanceTracker.h @@ -14,7 +14,7 @@ class PerformanceTracker { public: - PerformanceTracker(const std::optional<std::string> log_name = std::nullopt, + PerformanceTracker(std::optional<std::string> log_name = std::nullopt, const std::optional<DT> sample_window_duration = std::nullopt); ~PerformanceTracker() = default; diff --git a/Source/Core/VideoCommon/Resources/MaterialResource.cpp b/Source/Core/VideoCommon/Resources/MaterialResource.cpp index d41937d992..ea96cdf5f6 100644 --- a/Source/Core/VideoCommon/Resources/MaterialResource.cpp +++ b/Source/Core/VideoCommon/Resources/MaterialResource.cpp @@ -62,8 +62,8 @@ MaterialResource::MaterialResource(Resource::ResourceContext resource_context) } MaterialResource::MaterialResource(Resource::ResourceContext resource_context, - const GXPipelineUid& pipeline_uid) - : Resource(std::move(resource_context)), m_uid(pipeline_uid) + GXPipelineUid pipeline_uid) + : Resource(std::move(resource_context)), m_uid(std::move(pipeline_uid)) { m_material_asset = m_resource_context.asset_cache->CreateAsset<MaterialAsset>( m_resource_context.primary_asset_id, m_resource_context.asset_library, this); @@ -221,7 +221,7 @@ Resource::TaskComplete MaterialResource::ProcessData() VideoCommon::GXPipelineUid* uid, FramebufferState frame_buffer_state) : m_material_resource_data(std::move(material_resource_data)), m_shader_resource_data(std::move(shader_resource_data)), m_uid(uid), - m_frame_buffer_state(frame_buffer_state) + m_frame_buffer_state(std::move(frame_buffer_state)) { } diff --git a/Source/Core/VideoCommon/Resources/MaterialResource.h b/Source/Core/VideoCommon/Resources/MaterialResource.h index 6f4835927f..9729039d43 100644 --- a/Source/Core/VideoCommon/Resources/MaterialResource.h +++ b/Source/Core/VideoCommon/Resources/MaterialResource.h @@ -29,7 +29,7 @@ class MaterialResource final : public Resource { public: explicit MaterialResource(Resource::ResourceContext resource_context); - MaterialResource(Resource::ResourceContext resource_context, const GXPipelineUid& pipeline_uid); + MaterialResource(Resource::ResourceContext resource_context, GXPipelineUid pipeline_uid); struct TextureLikeReference { diff --git a/Source/Core/VideoCommon/Resources/ShaderResource.cpp b/Source/Core/VideoCommon/Resources/ShaderResource.cpp index 08aa994055..7b77886e2e 100644 --- a/Source/Core/VideoCommon/Resources/ShaderResource.cpp +++ b/Source/Core/VideoCommon/Resources/ShaderResource.cpp @@ -4,6 +4,7 @@ #include "VideoCommon/Resources/ShaderResource.h" #include <string_view> +#include <utility> #include <fmt/format.h> @@ -382,11 +383,11 @@ CompileVertexShader(VertexShaderUid* uid, std::string_view preprocessor_settings } } // namespace ShaderResource::ShaderResource(Resource::ResourceContext resource_context, - const std::optional<GXPipelineUid>& pipeline_uid, - const std::string& preprocessor_setting, + std::optional<GXPipelineUid> pipeline_uid, + std::string preprocessor_setting, const ShaderHostConfig& shader_host_config) : Resource(std::move(resource_context)), m_shader_host_config{.bits = shader_host_config.bits}, - m_uid(pipeline_uid), m_preprocessor_settings(preprocessor_setting) + m_uid(std::move(pipeline_uid)), m_preprocessor_settings(std::move(preprocessor_setting)) { m_shader_asset = m_resource_context.asset_cache->CreateAsset<RasterSurfaceShaderAsset>( m_resource_context.primary_asset_id, m_resource_context.asset_library, this); diff --git a/Source/Core/VideoCommon/Resources/ShaderResource.h b/Source/Core/VideoCommon/Resources/ShaderResource.h index 2f35087aab..1e59a1b11d 100644 --- a/Source/Core/VideoCommon/Resources/ShaderResource.h +++ b/Source/Core/VideoCommon/Resources/ShaderResource.h @@ -18,8 +18,7 @@ class ShaderResource final : public Resource { public: ShaderResource(Resource::ResourceContext resource_context, - const std::optional<GXPipelineUid>& pipeline_uid, - const std::string& preprocessor_settings, + std::optional<GXPipelineUid> pipeline_uid, std::string preprocessor_setting, const ShaderHostConfig& shader_host_config); class Data diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 22a5437046..2627656d0d 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -3,6 +3,8 @@ #include "VideoCommon/ShaderCache.h" +#include <utility> + #include <fmt/format.h> #include "Common/Assert.h" @@ -1018,8 +1020,8 @@ void ShaderCache::QueuePipelineCompile(const GXPipelineUid& uid, u32 priority) class PipelineWorkItem final : public AsyncShaderCompiler::WorkItem { public: - PipelineWorkItem(ShaderCache* shader_cache_, const GXPipelineUid& uid_, u32 priority_) - : shader_cache(shader_cache_), uid(uid_), priority(priority_) + PipelineWorkItem(ShaderCache* shader_cache_, GXPipelineUid uid_, u32 priority_) + : shader_cache(shader_cache_), uid(std::move(uid_)), priority(priority_) { // Check if all the stages required for this pipeline have been compiled. // If not, this work item becomes a no-op, and re-queues the pipeline for the next frame. @@ -1090,8 +1092,8 @@ void ShaderCache::QueueUberPipelineCompile(const GXUberPipelineUid& uid, u32 pri class UberPipelineWorkItem final : public AsyncShaderCompiler::WorkItem { public: - UberPipelineWorkItem(ShaderCache* shader_cache_, const GXUberPipelineUid& uid_, u32 priority_) - : shader_cache(shader_cache_), uid(uid_), priority(priority_) + UberPipelineWorkItem(ShaderCache* shader_cache_, GXUberPipelineUid uid_, u32 priority_) + : shader_cache(shader_cache_), uid(std::move(uid_)), priority(priority_) { // Check if all the stages required for this UberPipeline have been compiled. // If not, this work item becomes a no-op, and re-queues the UberPipeline for the next frame. diff --git a/Source/Core/VideoCommon/ShaderCompileUtils.cpp b/Source/Core/VideoCommon/ShaderCompileUtils.cpp index 297d86ea92..ee4adbf46e 100644 --- a/Source/Core/VideoCommon/ShaderCompileUtils.cpp +++ b/Source/Core/VideoCommon/ShaderCompileUtils.cpp @@ -4,14 +4,15 @@ #include "VideoCommon/ShaderCompileUtils.h" #include <ranges> +#include <utility> #include "Common/FileUtil.h" #include "Common/StringUtil.h" namespace VideoCommon { -ShaderIncluder::ShaderIncluder(const std::string& user_path, const std::string& system_path) - : m_root_user_path(user_path), m_root_system_path(system_path) +ShaderIncluder::ShaderIncluder(std::string user_path, std::string system_path) + : m_root_user_path(std::move(user_path)), m_root_system_path(std::move(system_path)) { } diff --git a/Source/Core/VideoCommon/ShaderCompileUtils.h b/Source/Core/VideoCommon/ShaderCompileUtils.h index 0e7c5eed5f..8bccca836c 100644 --- a/Source/Core/VideoCommon/ShaderCompileUtils.h +++ b/Source/Core/VideoCommon/ShaderCompileUtils.h @@ -15,7 +15,7 @@ namespace VideoCommon class ShaderIncluder final : public glslang::TShader::Includer { public: - ShaderIncluder(const std::string& user_path, const std::string& system_path); + ShaderIncluder(std::string user_path, std::string system_path); ~ShaderIncluder() override = default; std::vector<std::string> GetIncludes() const; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 952e4dee67..bbcd1140b4 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -657,7 +657,7 @@ void TextureCacheBase::DoSaveState(PointerWrap& p) } } - auto doList = [&p](auto list) { + auto doList = [&p](const auto& list) { u32 list_size = static_cast<u32>(list.size()); p.Do(list_size); for (const auto& it : list) |
