11 #include "utils/Map.h" 13 #include <fmt/format.h> 32 struct fmt::formatter<EShaderFormat> : fmt::formatter<std::string_view>
34 template<
typename FormatContext>
35 constexpr
auto format(
const EShaderFormat& shaderFormat, FormatContext& ctx)
37 const auto it = shaderFormatMap.find(shaderFormat);
38 if (it == shaderFormatMap.cend())
39 throw std::range_error(
"no shader format string found");
41 return fmt::formatter<string_view>::format(it->second, ctx);
45 static constexpr
auto shaderFormatMap = make_map<EShaderFormat, std::string_view>({
46 {SHADER_NONE,
"none"},
47 {SHADER_YV12,
"YV12"},
48 {SHADER_YV12_9,
"YV12 9bit"},
49 {SHADER_YV12_10,
"YV12 10bit"},
50 {SHADER_YV12_12,
"YV12 12bit"},
51 {SHADER_YV12_14,
"YV12 14bit"},
52 {SHADER_YV12_16,
"YV12 16bit"},
53 {SHADER_NV12,
"NV12"},
54 {SHADER_YUY2,
"YUY2"},
55 {SHADER_UYVY,
"UYVY"},
56 {SHADER_NV12_RRG,
"NV12 red/red/green"},
59 static_assert(SHADER_MAX == shaderFormatMap.size(),
60 "shaderFormatMap doesn't match the size of EShaderFormat, did you forget to " 61 "add/remove a mapping?");