From 333c9fdf6f3fc4d887c1b58da1cb1ac684b647c9 Mon Sep 17 00:00:00 2001
From: Stenzek <stenzek@gmail.com>
Date: Tue, 28 Nov 2023 13:51:04 +1000
Subject: [PATCH] Misc: Fix a couple of fmt errors

---
 src/common/small_string.h    | 35 +++++++++++++++++++++--------------
 src/util/opengl_pipeline.cpp |  6 +++---
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/src/common/small_string.h b/src/common/small_string.h
index 6f6b03282..36cfad665 100644
--- a/src/common/small_string.h
+++ b/src/common/small_string.h
@@ -329,18 +329,25 @@ ALWAYS_INLINE void SmallStringBase::fmt(fmt::format_string<T...> fmt, T&&... arg
 #pragma warning(pop)
 #endif
 
-template<>
-struct fmt::formatter<SmallStringBase>
-{
-  template<typename ParseContext>
-  constexpr auto parse(ParseContext& ctx)
-  {
-    return ctx.begin();
-  }
+#define MAKE_FORMATTER(type)                                                                                           \
+  template<>                                                                                                           \
+  struct fmt::formatter<type>                                                                                          \
+  {                                                                                                                    \
+    template<typename ParseContext>                                                                                    \
+    constexpr auto parse(ParseContext& ctx)                                                                            \
+    {                                                                                                                  \
+      return ctx.begin();                                                                                              \
+    }                                                                                                                  \
+                                                                                                                       \
+    template<typename FormatContext>                                                                                   \
+    auto format(const type& str, FormatContext& ctx)                                                                   \
+    {                                                                                                                  \
+      return fmt::format_to(ctx.out(), "{}", str.view());                                                              \
+    }                                                                                                                  \
+  };
 
-  template<typename FormatContext>
-  auto format(const SmallStringBase& str, FormatContext& ctx)
-  {
-    return fmt::format_to(ctx.out(), "{}", str.view());
-  }
-};
+MAKE_FORMATTER(TinyString);
+MAKE_FORMATTER(SmallString);
+MAKE_FORMATTER(LargeString);
+
+#undef MAKE_FORMATTER
diff --git a/src/util/opengl_pipeline.cpp b/src/util/opengl_pipeline.cpp
index d9048f99f..f53532215 100644
--- a/src/util/opengl_pipeline.cpp
+++ b/src/util/opengl_pipeline.cpp
@@ -358,9 +358,9 @@ GLuint OpenGLDevice::CompileProgram(const GPUPipeline::GraphicsConfig& plconfig)
       }
       else
       {
-        glBindAttribLocation(
-          program_id, i,
-          TinyString::from_fmt("{}{}", semantic_vars[static_cast<u8>(va.semantic.GetValue())], va.semantic_index));
+        glBindAttribLocation(program_id, i,
+                             TinyString::from_fmt("{}{}", semantic_vars[static_cast<u8>(va.semantic.GetValue())],
+                                                  static_cast<u8>(va.semantic_index)));
       }
     }