gl_shader_decompiler: Tidy up minor remaining cases of unnecessary std::string concatenation

This commit is contained in:
Lioncash 2019-05-14 18:12:29 -04:00
parent 6fb29764d6
commit 58a0c13e34

View file

@ -74,9 +74,7 @@ public:
} }
std::string GenerateTemporary() { std::string GenerateTemporary() {
std::string temporary = "tmp"; return fmt::format("tmp{}", temporary_index++);
temporary += std::to_string(temporary_index++);
return temporary;
} }
std::string GetResult() { std::string GetResult() {
@ -1748,24 +1746,25 @@ private:
} // Anonymous namespace } // Anonymous namespace
std::string GetCommonDeclarations() { std::string GetCommonDeclarations() {
const auto cbuf = std::to_string(MAX_CONSTBUFFER_ELEMENTS); return fmt::format(
return "#define MAX_CONSTBUFFER_ELEMENTS " + cbuf + "\n" + "#define MAX_CONSTBUFFER_ELEMENTS {}\n"
"#define ftoi floatBitsToInt\n" "#define ftoi floatBitsToInt\n"
"#define ftou floatBitsToUint\n" "#define ftou floatBitsToUint\n"
"#define itof intBitsToFloat\n" "#define itof intBitsToFloat\n"
"#define utof uintBitsToFloat\n\n" "#define utof uintBitsToFloat\n\n"
"float fromHalf2(vec2 pair) {\n" "float fromHalf2(vec2 pair) {{\n"
" return utof(packHalf2x16(pair));\n" " return utof(packHalf2x16(pair));\n"
"}\n\n" "}}\n\n"
"vec2 toHalf2(float value) {\n" "vec2 toHalf2(float value) {{\n"
" return unpackHalf2x16(ftou(value));\n" " return unpackHalf2x16(ftou(value));\n"
"}\n\n" "}}\n\n"
"bvec2 halfFloatNanComparison(bvec2 comparison, vec2 pair1, vec2 pair2) {\n" "bvec2 halfFloatNanComparison(bvec2 comparison, vec2 pair1, vec2 pair2) {{\n"
" bvec2 is_nan1 = isnan(pair1);\n" " bvec2 is_nan1 = isnan(pair1);\n"
" bvec2 is_nan2 = isnan(pair2);\n" " bvec2 is_nan2 = isnan(pair2);\n"
" return bvec2(comparison.x || is_nan1.x || is_nan2.x, comparison.y || is_nan1.y || " " return bvec2(comparison.x || is_nan1.x || is_nan2.x, comparison.y || is_nan1.y || "
"is_nan2.y);\n" "is_nan2.y);\n"
"}\n"; "}}\n",
MAX_CONSTBUFFER_ELEMENTS);
} }
ProgramResult Decompile(const Device& device, const ShaderIR& ir, Maxwell::ShaderStage stage, ProgramResult Decompile(const Device& device, const ShaderIR& ir, Maxwell::ShaderStage stage,