From 20139141f72f7d45eeb2d3c6ec4696af2d00e873 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Mon, 28 Dec 2020 16:50:23 +0100 Subject: [PATCH] video_core: Remove unnecessary enum class casting in logging messages fmt now automatically prints the numeric value of an enum class member by default, so we don't need to use casts any more. Reduces the line noise in our code a bit. Co-Authored-By: LC <712067+lioncash@users.noreply.github.com> --- src/video_core/regs_framebuffer.h | 6 ++-- src/video_core/regs_lighting.h | 2 +- .../renderer_opengl/gl_rasterizer_cache.cpp | 3 +- .../renderer_opengl/gl_shader_decompiler.cpp | 4 +-- .../renderer_opengl/gl_shader_disk_cache.cpp | 2 +- .../renderer_opengl/gl_shader_gen.cpp | 35 ++++++++----------- .../renderer_opengl/gl_shader_manager.cpp | 5 ++- src/video_core/renderer_opengl/pica_to_gl.h | 5 ++- src/video_core/swrasterizer/framebuffer.cpp | 2 +- src/video_core/swrasterizer/lighting.cpp | 2 +- src/video_core/swrasterizer/proctex.cpp | 6 ++-- src/video_core/swrasterizer/rasterizer.cpp | 2 +- 12 files changed, 32 insertions(+), 42 deletions(-) diff --git a/src/video_core/regs_framebuffer.h b/src/video_core/regs_framebuffer.h index 578c27e79..596682cbb 100644 --- a/src/video_core/regs_framebuffer.h +++ b/src/video_core/regs_framebuffer.h @@ -200,7 +200,7 @@ struct FramebufferRegs { case ColorFormat::RGBA4: return 2; default: - LOG_CRITICAL(HW_GPU, "Unknown color format {}", static_cast(format)); + LOG_CRITICAL(HW_GPU, "Unknown color format {}", format); UNIMPLEMENTED(); } } @@ -265,7 +265,7 @@ struct FramebufferRegs { return 4; } - ASSERT_MSG(false, "Unknown depth format {}", static_cast(format)); + ASSERT_MSG(false, "Unknown depth format {}", format); } // Returns the number of bits per depth component of the specified depth format @@ -278,7 +278,7 @@ struct FramebufferRegs { return 24; } - ASSERT_MSG(false, "Unknown depth format {}", static_cast(format)); + ASSERT_MSG(false, "Unknown depth format {}", format); } INSERT_PADDING_WORDS(0x10); // Gas related registers diff --git a/src/video_core/regs_lighting.h b/src/video_core/regs_lighting.h index 23405bd31..87911f947 100644 --- a/src/video_core/regs_lighting.h +++ b/src/video_core/regs_lighting.h @@ -127,7 +127,7 @@ struct LightingRegs { "sampler should be one of Distribution0, Distribution1, " "SpotlightAttenuation, Fresnel, ReflectRed, ReflectGreen or " "ReflectBlue, instead got %i", - static_cast(config)); + config); } } diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 88310a0ac..60cc34eba 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -747,8 +747,7 @@ void CachedSurface::DumpTexture(GLuint target_tex, u64 tex_hash) { return; } - dump_path += fmt::format("tex1_{}x{}_{:016X}_{}.png", width, height, tex_hash, - static_cast(pixel_format)); + dump_path += fmt::format("tex1_{}x{}_{:016X}_{}.png", width, height, tex_hash, pixel_format); if (!custom_tex_cache.IsTextureDumped(tex_hash) && !FileUtil::Exists(dump_path)) { custom_tex_cache.SetTextureDumped(tex_hash); diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index e52aa0869..bf165d9fb 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -561,9 +561,9 @@ private: const CompareOp op_y = instr.common.compare_op.y.Value(); if (cmp_ops.find(op_x) == cmp_ops.end()) { - LOG_ERROR(HW_GPU, "Unknown compare mode {:x}", static_cast(op_x)); + LOG_ERROR(HW_GPU, "Unknown compare mode {:x}", op_x); } else if (cmp_ops.find(op_y) == cmp_ops.end()) { - LOG_ERROR(HW_GPU, "Unknown compare mode {:x}", static_cast(op_y)); + LOG_ERROR(HW_GPU, "Unknown compare mode {:x}", op_y); } else if (op_x != op_y) { shader.AddLine("conditional_code.x = {}.x {} {}.x;", src1, cmp_ops.find(op_x)->second.first, src2); diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp index 2eca1b4a8..d9f516b50 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp @@ -161,7 +161,7 @@ std::optional> ShaderDiskCache::LoadTransferable } default: LOG_ERROR(Render_OpenGL, "Unknown transferable shader cache entry kind={} - skipping", - static_cast(kind)); + kind); return std::nullopt; } } diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 3172d610b..0f7357a3c 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -278,8 +278,7 @@ void PicaGSConfigCommonRaw::Init(const Pica::Regs& regs) { if (static_cast(semantic) < 24) { semantic_maps[static_cast(semantic)] = {attrib, comp}; } else if (semantic != VSOutputAttributes::INVALID) { - LOG_ERROR(Render_OpenGL, "Invalid/unknown semantic id: {}", - static_cast(semantic)); + LOG_ERROR(Render_OpenGL, "Invalid/unknown semantic id: {}", semantic); } } } @@ -316,8 +315,7 @@ static std::string SampleTexture(const PicaFSConfig& config, unsigned texture_un case TexturingRegs::TextureConfig::Disabled: return "vec4(0.0)"; default: - LOG_CRITICAL(HW_GPU, "Unhandled texture type {:x}", - static_cast(state.texture0_type)); + LOG_CRITICAL(HW_GPU, "Unhandled texture type {:x}", state.texture0_type); UNIMPLEMENTED(); return "texture(tex0, texcoord0)"; } @@ -380,7 +378,7 @@ static void AppendSource(std::string& out, const PicaFSConfig& config, break; default: out += "vec4(0.0)"; - LOG_CRITICAL(Render_OpenGL, "Unknown source op {}", static_cast(source)); + LOG_CRITICAL(Render_OpenGL, "Unknown source op {}", source); break; } } @@ -438,7 +436,7 @@ static void AppendColorModifier(std::string& out, const PicaFSConfig& config, break; default: out += "vec3(0.0)"; - LOG_CRITICAL(Render_OpenGL, "Unknown color modifier op {}", static_cast(modifier)); + LOG_CRITICAL(Render_OpenGL, "Unknown color modifier op {}", modifier); break; } } @@ -487,7 +485,7 @@ static void AppendAlphaModifier(std::string& out, const PicaFSConfig& config, break; default: out += "0.0"; - LOG_CRITICAL(Render_OpenGL, "Unknown alpha modifier op {}", static_cast(modifier)); + LOG_CRITICAL(Render_OpenGL, "Unknown alpha modifier op {}", modifier); break; } } @@ -529,8 +527,7 @@ static void AppendColorCombiner(std::string& out, TevStageConfig::Operation oper break; default: out += "vec3(0.0)"; - LOG_CRITICAL(Render_OpenGL, "Unknown color combiner operation: {}", - static_cast(operation)); + LOG_CRITICAL(Render_OpenGL, "Unknown color combiner operation: {}", operation); break; } out += ", vec3(0.0), vec3(1.0))"; // Clamp result to 0.0, 1.0 @@ -568,8 +565,7 @@ static void AppendAlphaCombiner(std::string& out, TevStageConfig::Operation oper break; default: out += "0.0"; - LOG_CRITICAL(Render_OpenGL, "Unknown alpha combiner operation: {}", - static_cast(operation)); + LOG_CRITICAL(Render_OpenGL, "Unknown alpha combiner operation: {}", operation); break; } out += ", 0.0, 1.0)"; @@ -599,7 +595,7 @@ static void AppendAlphaTestCondition(std::string& out, FramebufferRegs::CompareF default: out += "false"; - LOG_CRITICAL(Render_OpenGL, "Unknown alpha test condition {}", static_cast(func)); + LOG_CRITICAL(Render_OpenGL, "Unknown alpha test condition {}", func); break; } } @@ -831,8 +827,7 @@ static void WriteLighting(std::string& out, const PicaFSConfig& config) { "{}.position) + {}.dist_atten_bias, 0.0, 1.0)", light_src, light_src, light_src); const auto sampler = LightingRegs::DistanceAttenuationSampler(light_config.num); - dist_atten = - fmt::format("LookupLightingLUTUnsigned({}, {})", static_cast(sampler), index); + dist_atten = fmt::format("LookupLightingLUTUnsigned({}, {})", sampler, index); } if (light_config.geometric_factor_0 || light_config.geometric_factor_1) { @@ -985,7 +980,7 @@ static void AppendProcTexShiftOffset(std::string& out, std::string_view v, ProcT out += fmt::format("{} * float(((int({}) + 1) / 2) % 2)", offset, v); break; default: - LOG_CRITICAL(HW_GPU, "Unknown shift mode {}", static_cast(mode)); + LOG_CRITICAL(HW_GPU, "Unknown shift mode {}", mode); out += "0.0"; break; } @@ -1010,7 +1005,7 @@ static void AppendProcTexClamp(std::string& out, std::string_view var, ProcTexCl out += fmt::format("{0} = {0} > 0.5 ? 1.0 : 0.0;\n", var); break; default: - LOG_CRITICAL(HW_GPU, "Unknown clamp mode {}", static_cast(mode)); + LOG_CRITICAL(HW_GPU, "Unknown clamp mode {}", mode); out += fmt::format("{0} = min({0}, 1.0);\n", var); break; } @@ -1041,7 +1036,7 @@ static void AppendProcTexCombineAndMap(std::string& out, ProcTexCombiner combine case TexturingRegs::ProcTexCombiner::RMax: return "min(((u + v) * 0.5 + sqrt(u * u + v * v)) * 0.5, 1.0)"; default: - LOG_CRITICAL(HW_GPU, "Unknown combiner {}", static_cast(combiner)); + LOG_CRITICAL(HW_GPU, "Unknown combiner {}", combiner); return "0.0"; } }(); @@ -1592,10 +1587,8 @@ ShaderDecompiler::ProgramResult GenerateTrivialVertexShader(bool separable_shade "layout(location = {}) in float vert_texcoord0_w;\n" "layout(location = {}) in vec4 vert_normquat;\n" "layout(location = {}) in vec3 vert_view;\n", - static_cast(ATTRIBUTE_POSITION), static_cast(ATTRIBUTE_COLOR), - static_cast(ATTRIBUTE_TEXCOORD0), static_cast(ATTRIBUTE_TEXCOORD1), - static_cast(ATTRIBUTE_TEXCOORD2), static_cast(ATTRIBUTE_TEXCOORD0_W), - static_cast(ATTRIBUTE_NORMQUAT), static_cast(ATTRIBUTE_VIEW)); + ATTRIBUTE_POSITION, ATTRIBUTE_COLOR, ATTRIBUTE_TEXCOORD0, ATTRIBUTE_TEXCOORD1, + ATTRIBUTE_TEXCOORD2, ATTRIBUTE_TEXCOORD0_W, ATTRIBUTE_NORMQUAT, ATTRIBUTE_VIEW); out += GetVertexInterfaceDeclaration(true, separable_shader); diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index 51ed235de..ccbcc8875 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -524,7 +524,7 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading, // Unsupported shader type got stored somehow so nuke the cache LOG_CRITICAL(Frontend, "failed to load raw programtype {}", - static_cast(raw.GetProgramType())); + raw.GetProgramType()); compilation_failed = true; return; } @@ -585,8 +585,7 @@ void ShaderProgramManager::LoadDiskCache(const std::atomic_bool& stop_loading, result = std::move(r); } else { // Unsupported shader type got stored somehow so nuke the cache - LOG_ERROR(Frontend, "failed to load raw programtype {}", - static_cast(raw.GetProgramType())); + LOG_ERROR(Frontend, "failed to load raw programtype {}", raw.GetProgramType()); compilation_failed = true; return; } diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h index ce25f7907..6ce1144d3 100644 --- a/src/video_core/renderer_opengl/pica_to_gl.h +++ b/src/video_core/renderer_opengl/pica_to_gl.h @@ -38,7 +38,7 @@ inline GLenum TextureMagFilterMode(TextureFilter mode) { if (mode == TextureFilter::Nearest) { return GL_NEAREST; } - LOG_CRITICAL(Render_OpenGL, "Unknown texture filtering mode {}", static_cast(mode)); + LOG_CRITICAL(Render_OpenGL, "Unknown texture filtering mode {}", mode); UNIMPLEMENTED(); return GL_LINEAR; } @@ -59,8 +59,7 @@ inline GLenum TextureMinFilterMode(TextureFilter min, TextureFilter mip) { return GL_NEAREST_MIPMAP_NEAREST; } } - LOG_CRITICAL(Render_OpenGL, "Unknown texture filtering mode {} and {}", static_cast(min), - static_cast(mip)); + LOG_CRITICAL(Render_OpenGL, "Unknown texture filtering mode {} and {}", min, mip); UNIMPLEMENTED(); return GL_LINEAR_MIPMAP_LINEAR; } diff --git a/src/video_core/swrasterizer/framebuffer.cpp b/src/video_core/swrasterizer/framebuffer.cpp index 9a0d6b8bf..9bcb0cde0 100644 --- a/src/video_core/swrasterizer/framebuffer.cpp +++ b/src/video_core/swrasterizer/framebuffer.cpp @@ -297,7 +297,7 @@ Common::Vec4 EvaluateBlendEquation(const Common::Vec4& src, break; default: - LOG_CRITICAL(HW_GPU, "Unknown RGB blend equation 0x{:x}", static_cast(equation)); + LOG_CRITICAL(HW_GPU, "Unknown RGB blend equation 0x{:x}", equation); UNIMPLEMENTED(); } diff --git a/src/video_core/swrasterizer/lighting.cpp b/src/video_core/swrasterizer/lighting.cpp index 3f9ab001e..03820c946 100644 --- a/src/video_core/swrasterizer/lighting.cpp +++ b/src/video_core/swrasterizer/lighting.cpp @@ -143,7 +143,7 @@ std::tuple, Common::Vec4> ComputeFragmentsColors( } break; default: - LOG_CRITICAL(HW_GPU, "Unknown lighting LUT input {}", static_cast(input)); + LOG_CRITICAL(HW_GPU, "Unknown lighting LUT input {}", input); UNIMPLEMENTED(); result = 0.0f; } diff --git a/src/video_core/swrasterizer/proctex.cpp b/src/video_core/swrasterizer/proctex.cpp index 23f7630de..dc0b1e5d8 100644 --- a/src/video_core/swrasterizer/proctex.cpp +++ b/src/video_core/swrasterizer/proctex.cpp @@ -76,7 +76,7 @@ static float GetShiftOffset(float v, ProcTexShift mode, ProcTexClamp clamp_mode) case ProcTexShift::Even: return offset * ((((int)v + 1) / 2) % 2); default: - LOG_CRITICAL(HW_GPU, "Unknown shift mode {}", static_cast(mode)); + LOG_CRITICAL(HW_GPU, "Unknown shift mode {}", mode); return 0; } }; @@ -106,7 +106,7 @@ static void ClampCoord(float& coord, ProcTexClamp mode) { coord = 1.0f; break; default: - LOG_CRITICAL(HW_GPU, "Unknown clamp mode {}", static_cast(mode)); + LOG_CRITICAL(HW_GPU, "Unknown clamp mode {}", mode); coord = std::min(coord, 1.0f); break; } @@ -147,7 +147,7 @@ static float CombineAndMap(float u, float v, ProcTexCombiner combiner, f = std::min(((u + v) * 0.5f + std::sqrt(u * u + v * v)) * 0.5f, 1.0f); break; default: - LOG_CRITICAL(HW_GPU, "Unknown combiner {}", static_cast(combiner)); + LOG_CRITICAL(HW_GPU, "Unknown combiner {}", combiner); f = 0.0f; break; } diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp index 5035b41e1..4cd8bbc91 100644 --- a/src/video_core/swrasterizer/rasterizer.cpp +++ b/src/video_core/swrasterizer/rasterizer.cpp @@ -847,7 +847,7 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve return std::min(combiner_output.a(), static_cast(255 - dest.a())); default: - LOG_CRITICAL(HW_GPU, "Unknown blend factor {:x}", static_cast(factor)); + LOG_CRITICAL(HW_GPU, "Unknown blend factor {:x}", factor); UNIMPLEMENTED(); break; }