mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-10-02 07:06:59 -05:00
Improve usage of std::move and const references parameters
Accomplished using `run-clang-tidy` with `performance-move-const-arg,performance-unnecessary-value-param,modernize-pass-by-value`. Changed arguments to const references, removed them where inappropriate (e.g. sink parameters). Same with std::move. Manually reviewed each change to make sure that it makes sense, and do something more appropriate if possible.
This commit is contained in:
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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&)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user