summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-12-22 13:05:42 -0500
committerLioncash <mathew1800@gmail.com>2020-05-25 21:12:29 -0400
commite3506ff4ef48092a69dbe5d80b728d86b2d212fa (patch)
tree6f444205165eb76e1b94ca60a638cd1ceb813456 /Source
parent68706973d2c190d1a683c2e6a33d7515618bb930 (diff)
VideoCommon/ShaderGenCommon: Convert helper functions over to fmt
A very trivial conversion, this simply converts calls to Write over to WriteFmt and adjusts the formatting specifiers as necessary. This also allows the const char* parameters to become std::string_view instances, allowing for ease of use with other string types.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/VideoCommon/ShaderGenCommon.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/Source/Core/VideoCommon/ShaderGenCommon.h b/Source/Core/VideoCommon/ShaderGenCommon.h
index 889a446df8..5e7fa49f3d 100644
--- a/Source/Core/VideoCommon/ShaderGenCommon.h
+++ b/Source/Core/VideoCommon/ShaderGenCommon.h
@@ -194,29 +194,29 @@ std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool
bool include_host_config, bool include_api = true);
template <class T>
-inline void DefineOutputMember(T& object, APIType api_type, const char* qualifier, const char* type,
- const char* name, int var_index, const char* semantic = "",
- int semantic_index = -1)
+void DefineOutputMember(T& object, APIType api_type, std::string_view qualifier,
+ std::string_view type, std::string_view name, int var_index,
+ std::string_view semantic = {}, int semantic_index = -1)
{
- object.Write("\t%s %s %s", qualifier, type, name);
+ object.WriteFmt("\t{} {} {}", qualifier, type, name);
if (var_index != -1)
- object.Write("%d", var_index);
+ object.WriteFmt("{}", var_index);
- if (api_type == APIType::D3D && strlen(semantic) > 0)
+ if (api_type == APIType::D3D && !semantic.empty())
{
if (semantic_index != -1)
- object.Write(" : %s%d", semantic, semantic_index);
+ object.WriteFmt(" : {}{}", semantic, semantic_index);
else
- object.Write(" : %s", semantic);
+ object.WriteFmt(" : {}", semantic);
}
- object.Write(";\n");
+ object.WriteFmt(";\n");
}
template <class T>
-inline void GenerateVSOutputMembers(T& object, APIType api_type, u32 texgens,
- const ShaderHostConfig& host_config, const char* qualifier)
+void GenerateVSOutputMembers(T& object, APIType api_type, u32 texgens,
+ const ShaderHostConfig& host_config, std::string_view qualifier)
{
DefineOutputMember(object, api_type, qualifier, "float4", "pos", -1, "SV_Position");
DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 0, "COLOR", 0);
@@ -244,29 +244,29 @@ inline void GenerateVSOutputMembers(T& object, APIType api_type, u32 texgens,
}
template <class T>
-inline void AssignVSOutputMembers(T& object, const char* a, const char* b, u32 texgens,
- const ShaderHostConfig& host_config)
+void AssignVSOutputMembers(T& object, std::string_view a, std::string_view b, u32 texgens,
+ const ShaderHostConfig& host_config)
{
- object.Write("\t%s.pos = %s.pos;\n", a, b);
- object.Write("\t%s.colors_0 = %s.colors_0;\n", a, b);
- object.Write("\t%s.colors_1 = %s.colors_1;\n", a, b);
+ object.WriteFmt("\t{}.pos = {}.pos;\n", a, b);
+ object.WriteFmt("\t{}.colors_0 = {}.colors_0;\n", a, b);
+ object.WriteFmt("\t{}.colors_1 = {}.colors_1;\n", a, b);
for (unsigned int i = 0; i < texgens; ++i)
- object.Write("\t%s.tex%d = %s.tex%d;\n", a, i, b, i);
+ object.WriteFmt("\t{}.tex{} = {}.tex{};\n", a, i, b, i);
if (!host_config.fast_depth_calc)
- object.Write("\t%s.clipPos = %s.clipPos;\n", a, b);
+ object.WriteFmt("\t{}.clipPos = {}.clipPos;\n", a, b);
if (host_config.per_pixel_lighting)
{
- object.Write("\t%s.Normal = %s.Normal;\n", a, b);
- object.Write("\t%s.WorldPos = %s.WorldPos;\n", a, b);
+ object.WriteFmt("\t{}.Normal = {}.Normal;\n", a, b);
+ object.WriteFmt("\t{}.WorldPos = {}.WorldPos;\n", a, b);
}
if (host_config.backend_geometry_shaders)
{
- object.Write("\t%s.clipDist0 = %s.clipDist0;\n", a, b);
- object.Write("\t%s.clipDist1 = %s.clipDist1;\n", a, b);
+ object.WriteFmt("\t{}.clipDist0 = {}.clipDist0;\n", a, b);
+ object.WriteFmt("\t{}.clipDist1 = {}.clipDist1;\n", a, b);
}
}