From 353ceedb50701b487bf975433f89788d72489930 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 31 Jan 2024 22:52:07 -0500 Subject: [PATCH 1/3] CustomPipeline: Resolve unused variable warning We can just use holds_alternative here instead. --- .../VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp index d6144adea3..549088042f 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp @@ -197,8 +197,7 @@ void CustomPipeline::UpdatePixelData( { max_material_data_size += VideoCommon::MaterialProperty::GetMemorySize(property); VideoCommon::MaterialProperty::WriteAsShaderCode(m_last_generated_material_code, property); - if (auto* texture_asset_id = - std::get_if(&property.m_value)) + if (std::holds_alternative(property.m_value)) { texture_count++; } From 59211589b9999acd1f18460e39c13c3ddd683d55 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 31 Jan 2024 22:53:42 -0500 Subject: [PATCH 2/3] CustomPipeline: Make use of emplace_back() in GlobalConflicts() We can use the string_view arguments to directly construct strings inside of the global_result vector. --- .../GraphicsModSystem/Runtime/CustomPipeline.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp index 549088042f..178719ba2d 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp @@ -101,7 +101,7 @@ std::vector GlobalConflicts(std::string_view source) { i++; } - global_result.push_back(std::string{parse_identifier()}); + global_result.emplace_back(parse_identifier()); parse_until_end_of_preprocessor(); } else @@ -121,11 +121,11 @@ std::vector GlobalConflicts(std::string_view source) // Since we handle equality, we can assume the identifier // before '(' is a function definition - global_result.push_back(std::string{last_identifier}); + global_result.emplace_back(last_identifier); } else if (source[i] == '=') { - global_result.push_back(std::string{last_identifier}); + global_result.emplace_back(last_identifier); i++; for (; i < source.size(); i++) { From 7096f99f7992481c0cbb1e006501c9946a61dad2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 31 Jan 2024 22:55:41 -0500 Subject: [PATCH 3/3] CustomPipeline: Mark arrays as constexpr Ensures that these go into the ro section. --- .../GraphicsModSystem/Runtime/CustomPipeline.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp index 178719ba2d..46ca20cc38 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp @@ -17,15 +17,17 @@ namespace { bool IsQualifier(std::string_view value) { - static std::array qualifiers = {"attribute", "const", "highp", "lowp", - "mediump", "uniform", "varying"}; + static constexpr std::array qualifiers = { + "attribute", "const", "highp", "lowp", "mediump", "uniform", "varying", + }; return std::find(qualifiers.begin(), qualifiers.end(), value) != qualifiers.end(); } bool IsBuiltInMacro(std::string_view value) { - static std::array built_in = {"__LINE__", "__FILE__", "__VERSION__", - "GL_core_profile", "GL_compatibility_profile"}; + static constexpr std::array built_in = { + "__LINE__", "__FILE__", "__VERSION__", "GL_core_profile", "GL_compatibility_profile", + }; return std::find(built_in.begin(), built_in.end(), value) != built_in.end(); }