summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorJoshua Vandaƫle <joshua@vandaele.software>2026-01-09 23:49:10 +0100
committerJoshua Vandaƫle <joshua@vandaele.software>2026-01-09 23:49:10 +0100
commit55f0715ad4edf4485bc7b35e49fbd883ce760e47 (patch)
tree2b016eb261d2138a56c00a682abfefa96174a696 /Source/Core/VideoCommon
parentcc0ce62e7ff283919c95c12a1c8e3b0887271690 (diff)
c++23: Replace Common::ToUnderlying with std::to_underlying
Requires at least GCC 11, Clang 13, MSVC 19.30 (VS2022 17.0), or AppleClang 13.1.6 (XCode 13.3).
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/CPMemory.cpp10
-rw-r--r--Source/Core/VideoCommon/Resources/MaterialResource.cpp4
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp3
-rw-r--r--Source/Core/VideoCommon/UberShaderCommon.cpp7
-rw-r--r--Source/Core/VideoCommon/UberShaderVertex.cpp31
5 files changed, 29 insertions, 26 deletions
diff --git a/Source/Core/VideoCommon/CPMemory.cpp b/Source/Core/VideoCommon/CPMemory.cpp
index 9b47a13da0..2efb000d90 100644
--- a/Source/Core/VideoCommon/CPMemory.cpp
+++ b/Source/Core/VideoCommon/CPMemory.cpp
@@ -5,9 +5,9 @@
#include <cstring>
#include <type_traits>
+#include <utility>
#include "Common/ChunkFile.h"
-#include "Common/EnumUtils.h"
#include "Common/Logging/Log.h"
#include "Core/DolphinAnalytics.h"
#include "Core/System.h"
@@ -112,7 +112,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value)
WARN_LOG_FMT(VIDEO,
"CP MATINDEX_A: an exact value of {:02x} was expected "
"but instead a value of {:02x} was seen",
- Common::ToUnderlying(MATINDEX_A), sub_cmd);
+ std::to_underlying(MATINDEX_A), sub_cmd);
}
matrix_index_a.Hex = value;
@@ -125,7 +125,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value)
WARN_LOG_FMT(VIDEO,
"CP MATINDEX_B: an exact value of {:02x} was expected "
"but instead a value of {:02x} was seen",
- Common::ToUnderlying(MATINDEX_B), sub_cmd);
+ std::to_underlying(MATINDEX_B), sub_cmd);
}
matrix_index_b.Hex = value;
@@ -138,7 +138,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value)
WARN_LOG_FMT(VIDEO,
"CP VCD_LO: an exact value of {:02x} was expected "
"but instead a value of {:02x} was seen",
- Common::ToUnderlying(VCD_LO), sub_cmd);
+ std::to_underlying(VCD_LO), sub_cmd);
}
vtx_desc.low.Hex = value;
@@ -151,7 +151,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value)
WARN_LOG_FMT(VIDEO,
"CP VCD_HI: an exact value of {:02x} was expected "
"but instead a value of {:02x} was seen",
- Common::ToUnderlying(VCD_HI), sub_cmd);
+ std::to_underlying(VCD_HI), sub_cmd);
}
vtx_desc.high.Hex = value;
diff --git a/Source/Core/VideoCommon/Resources/MaterialResource.cpp b/Source/Core/VideoCommon/Resources/MaterialResource.cpp
index 657647ffb9..38486d7932 100644
--- a/Source/Core/VideoCommon/Resources/MaterialResource.cpp
+++ b/Source/Core/VideoCommon/Resources/MaterialResource.cpp
@@ -3,6 +3,8 @@
#include "VideoCommon/Resources/MaterialResource.h"
+#include <utility>
+
#include <xxh3.h>
#include "Common/VariantUtil.h"
@@ -30,7 +32,7 @@ SamplerState CalculateSamplerAnisotropy(const SamplerState& initial_sampler)
if (g_ActiveConfig.iMaxAnisotropy != AnisotropicFilteringMode::Default &&
IsAnisotropicEnhancementSafe(state.tm0))
{
- state.tm0.anisotropic_filtering = Common::ToUnderlying(g_ActiveConfig.iMaxAnisotropy);
+ state.tm0.anisotropic_filtering = std::to_underlying(g_ActiveConfig.iMaxAnisotropy);
}
if (state.tm0.anisotropic_filtering != 0)
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index 6ae8b4f96f..2b1fab27b5 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -21,7 +21,6 @@
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
-#include "Common/EnumUtils.h"
#include "Common/FileUtil.h"
#include "Common/Hash.h"
#include "Common/Logging/Log.h"
@@ -1031,7 +1030,7 @@ SamplerState TextureCacheBase::GetSamplerState(u32 index, float custom_tex_scale
if (g_ActiveConfig.iMaxAnisotropy != AnisotropicFilteringMode::Default &&
IsAnisotropicEnhancementSafe(tm0))
{
- state.tm0.anisotropic_filtering = Common::ToUnderlying(g_ActiveConfig.iMaxAnisotropy);
+ state.tm0.anisotropic_filtering = std::to_underlying(g_ActiveConfig.iMaxAnisotropy);
}
if (state.tm0.anisotropic_filtering != 0)
diff --git a/Source/Core/VideoCommon/UberShaderCommon.cpp b/Source/Core/VideoCommon/UberShaderCommon.cpp
index d35f203737..f605081481 100644
--- a/Source/Core/VideoCommon/UberShaderCommon.cpp
+++ b/Source/Core/VideoCommon/UberShaderCommon.cpp
@@ -3,7 +3,8 @@
#include "VideoCommon/UberShaderCommon.h"
-#include "Common/EnumUtils.h"
+#include <utility>
+
#include "VideoCommon/NativeVertexFormat.h"
#include "VideoCommon/ShaderGenCommon.h"
#include "VideoCommon/VideoCommon.h"
@@ -120,11 +121,11 @@ void WriteVertexLighting(ShaderCode& out, APIType api_type, std::string_view wor
out.Write(" if ({} != 0u) {{\n", BitfieldExtract<&LitChannel::enablelighting>("alphareg"));
out.Write(" if ({} != 0u) {{\n", BitfieldExtract<&LitChannel::ambsource>("alphareg"));
out.Write(" if ((components & ({}u << chan)) != 0u) // VB_HAS_COL0\n",
- Common::ToUnderlying(VB_HAS_COL0));
+ std::to_underlying(VB_HAS_COL0));
out.Write(" lacc.w = int(round(((chan == 0u) ? {}.w : {}.w) * 255.0));\n", in_color_0_var,
in_color_1_var);
out.Write(" else if ((components & {}u) != 0u) // VB_HAS_COLO0\n",
- Common::ToUnderlying(VB_HAS_COL0));
+ std::to_underlying(VB_HAS_COL0));
out.Write(" lacc.w = int(round({}.w * 255.0));\n", in_color_0_var);
out.Write(" else\n"
" lacc.w = 255;\n"
diff --git a/Source/Core/VideoCommon/UberShaderVertex.cpp b/Source/Core/VideoCommon/UberShaderVertex.cpp
index a6c0502dfe..e558637d97 100644
--- a/Source/Core/VideoCommon/UberShaderVertex.cpp
+++ b/Source/Core/VideoCommon/UberShaderVertex.cpp
@@ -3,7 +3,8 @@
#include "VideoCommon/UberShaderVertex.h"
-#include "Common/EnumUtils.h"
+#include <utility>
+
#include "VideoCommon/ConstantManager.h"
#include "VideoCommon/DriverDetails.h"
#include "VideoCommon/NativeVertexFormat.h"
@@ -224,7 +225,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
"float3 N2;\n"
"\n"
"if ((components & {}u) != 0u) {{ // VB_HAS_POSMTXIDX\n",
- Common::ToUnderlying(VB_HAS_POSMTXIDX));
+ std::to_underlying(VB_HAS_POSMTXIDX));
LoadVertexAttribute(out, host_config, 2, "posmtx", "uint4", "ubyte4");
out.Write(" // Vertex format has a per-vertex matrix\n"
" int posidx = int(posmtx.r);\n"
@@ -256,7 +257,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
"float3 _rawbinormal;\n"
"if ((components & {}u) != 0u) // VB_HAS_NORMAL\n"
"{{\n",
- Common::ToUnderlying(VB_HAS_NORMAL));
+ std::to_underlying(VB_HAS_NORMAL));
LoadVertexAttribute(out, host_config, 2, "rawnormal", "float3", "float3");
out.Write(" _rawnormal = rawnormal;\n"
"}}\n"
@@ -267,7 +268,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
"\n"
"if ((components & {}u) != 0u) // VB_HAS_TANGENT\n"
"{{\n",
- Common::ToUnderlying(VB_HAS_TANGENT));
+ std::to_underlying(VB_HAS_TANGENT));
LoadVertexAttribute(out, host_config, 2, "rawtangent", "float3", "float3");
out.Write(" _rawtangent = rawtangent;\n"
"}}\n"
@@ -278,7 +279,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
"\n"
"if ((components & {}u) != 0u) // VB_HAS_BINORMAL\n"
"{{\n",
- Common::ToUnderlying(VB_HAS_BINORMAL));
+ std::to_underlying(VB_HAS_BINORMAL));
LoadVertexAttribute(out, host_config, 2, "rawbinormal", "float3", "float3");
out.Write(" _rawbinormal = rawbinormal;\n"
"}}\n"
@@ -320,14 +321,14 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
"}}\n"
"else if ((components & {}u) != 0u) // VB_HAS_COL0\n"
"{{\n",
- Common::ToUnderlying(VB_HAS_COL0));
+ std::to_underlying(VB_HAS_COL0));
LoadVertexAttribute(out, host_config, 2, "rawcolor0", "float4", "ubyte4");
out.Write(" vertex_color_0 = rawcolor0;\n"
" vertex_color_1 = rawcolor0;\n"
"}}\n"
"else if ((components & {}u) != 0u) // VB_HAS_COL1\n"
"{{\n",
- Common::ToUnderlying(VB_HAS_COL1));
+ std::to_underlying(VB_HAS_COL1));
LoadVertexAttribute(out, host_config, 2, "rawcolor1", "float4", "ubyte4");
out.Write(" vertex_color_0 = rawcolor1;\n"
" vertex_color_1 = rawcolor1;\n"
@@ -347,7 +348,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
if (host_config.backend_vs_point_line_expand)
{
- out.Write("if (vs_expand == {}u) {{ // Line\n", Common::ToUnderlying(VSExpand::Line));
+ out.Write("if (vs_expand == {}u) {{ // Line\n", std::to_underlying(VSExpand::Line));
out.Write(" bool is_bottom = (gl_VertexID & 2) != 0;\n"
" bool is_right = (gl_VertexID & 1) != 0;\n"
" uint other_base_offset = vertex_base_offset;\n"
@@ -362,7 +363,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
" float4 other_p1 = P1;\n"
" float4 other_p2 = P2;\n"
" if ((components & {}u) != 0u) {{ // VB_HAS_POSMTXIDX\n",
- Common::ToUnderlying(VB_HAS_POSMTXIDX));
+ std::to_underlying(VB_HAS_POSMTXIDX));
out.Write(" uint other_posidx = load_input_uint4_ubyte4(other_base_offset, "
"vertex_offset_posmtx).r;\n"
" other_p0 = " I_TRANSFORMMATRICES "[other_posidx];\n"
@@ -372,7 +373,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
" float4 other_pos = float4(dot(other_p0, other_rawpos), "
"dot(other_p1, other_rawpos), dot(other_p2, other_rawpos), 1.0);\n");
GenerateVSLineExpansion(out, " ", num_texgen);
- out.Write("}} else if (vs_expand == {}u) {{ // Point\n", Common::ToUnderlying(VSExpand::Point));
+ out.Write("}} else if (vs_expand == {}u) {{ // Point\n", std::to_underlying(VSExpand::Point));
out.Write(" bool is_bottom = (gl_VertexID & 2) != 0;\n"
" bool is_right = (gl_VertexID & 1) != 0;\n");
GenerateVSPointExpansion(out, " ", num_texgen);
@@ -552,7 +553,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos
out.Write(" case {:s}:\n", SourceRow::Normal);
out.Write(" if ((components & {}u) != 0u) // VB_HAS_NORMAL\n"
" {{\n",
- Common::ToUnderlying(VB_HAS_NORMAL));
+ std::to_underlying(VB_HAS_NORMAL));
LoadVertexAttribute(out, host_config, 6, "rawnormal", "float3", "float3");
out.Write(" coord.xyz = rawnormal.xyz;\n"
" }}\n"
@@ -560,7 +561,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos
out.Write(" case {:s}:\n", SourceRow::BinormalT);
out.Write(" if ((components & {}u) != 0u) // VB_HAS_TANGENT\n"
" {{\n",
- Common::ToUnderlying(VB_HAS_TANGENT));
+ std::to_underlying(VB_HAS_TANGENT));
LoadVertexAttribute(out, host_config, 6, "rawtangent", "float3", "float3");
out.Write(" coord.xyz = rawtangent.xyz;\n"
" }}\n"
@@ -568,14 +569,14 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos
out.Write(" case {:s}:\n", SourceRow::BinormalB);
out.Write(" if ((components & {}u) != 0u) // VB_HAS_BINORMAL\n"
" {{\n",
- Common::ToUnderlying(VB_HAS_BINORMAL));
+ std::to_underlying(VB_HAS_BINORMAL));
LoadVertexAttribute(out, host_config, 6, "rawbinormal", "float3", "float3");
out.Write(" coord.xyz = rawbinormal.xyz;\n"
" }}\n"
" break;\n\n");
for (u32 i = 0; i < 8; i++)
{
- out.Write(" case {:s}:\n", static_cast<SourceRow>(Common::ToUnderlying(SourceRow::Tex0) + i));
+ out.Write(" case {:s}:\n", static_cast<SourceRow>(std::to_underlying(SourceRow::Tex0) + i));
out.Write(" if ((components & {}u) != 0u) // VB_HAS_UV{}\n"
" {{\n",
VB_HAS_UV0 << i, i);
@@ -632,7 +633,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos
out.Write(" default:\n"
" {{\n");
out.Write(" if ((components & ({}u /* VB_HAS_TEXMTXIDX0 */ << texgen)) != 0u) {{\n",
- Common::ToUnderlying(VB_HAS_TEXMTXIDX0));
+ std::to_underlying(VB_HAS_TEXMTXIDX0));
if (host_config.backend_dynamic_vertex_loader || host_config.backend_vs_point_line_expand)
{
out.Write(" int tmp = int(load_input_float3_rawtex(vertex_base_offset, "