glsl_shader_decompiler: Add AddNewLine() function to ShaderWriter
Avoids constructing a std::string just to append a newline character
This commit is contained in:
parent
aa26baa3db
commit
412b31ad72
1 changed files with 12 additions and 6 deletions
|
@ -114,13 +114,19 @@ public:
|
||||||
if (!text.empty()) {
|
if (!text.empty()) {
|
||||||
AppendIndentation();
|
AppendIndentation();
|
||||||
}
|
}
|
||||||
shader_source += text + '\n';
|
shader_source += text;
|
||||||
|
AddNewLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLine(char character) {
|
void AddLine(char character) {
|
||||||
DEBUG_ASSERT(scope >= 0);
|
DEBUG_ASSERT(scope >= 0);
|
||||||
AppendIndentation();
|
AppendIndentation();
|
||||||
shader_source += character;
|
shader_source += character;
|
||||||
|
AddNewLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddNewLine() {
|
||||||
|
DEBUG_ASSERT(scope >= 0);
|
||||||
shader_source += '\n';
|
shader_source += '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +481,7 @@ private:
|
||||||
for (const auto& subroutine : subroutines) {
|
for (const auto& subroutine : subroutines) {
|
||||||
shader.AddLine("bool " + subroutine.GetName() + "();");
|
shader.AddLine("bool " + subroutine.GetName() + "();");
|
||||||
}
|
}
|
||||||
shader.AddLine("");
|
shader.AddNewLine();
|
||||||
|
|
||||||
// Add the main entry point
|
// Add the main entry point
|
||||||
shader.AddLine("bool exec_shader() {");
|
shader.AddLine("bool exec_shader() {");
|
||||||
|
@ -552,7 +558,7 @@ private:
|
||||||
for (const auto& reg : declr_register) {
|
for (const auto& reg : declr_register) {
|
||||||
declarations.AddLine("float " + reg + " = 0.0;");
|
declarations.AddLine("float " + reg + " = 0.0;");
|
||||||
}
|
}
|
||||||
declarations.AddLine("");
|
declarations.AddNewLine();
|
||||||
|
|
||||||
for (const auto& index : declr_input_attribute) {
|
for (const auto& index : declr_input_attribute) {
|
||||||
// TODO(bunnei): Use proper number of elements for these
|
// TODO(bunnei): Use proper number of elements for these
|
||||||
|
@ -561,7 +567,7 @@ private:
|
||||||
static_cast<u32>(Attribute::Index::Attribute_0)) +
|
static_cast<u32>(Attribute::Index::Attribute_0)) +
|
||||||
") in vec4 " + GetInputAttribute(index) + ";");
|
") in vec4 " + GetInputAttribute(index) + ";");
|
||||||
}
|
}
|
||||||
declarations.AddLine("");
|
declarations.AddNewLine();
|
||||||
|
|
||||||
for (const auto& index : declr_output_attribute) {
|
for (const auto& index : declr_output_attribute) {
|
||||||
// TODO(bunnei): Use proper number of elements for these
|
// TODO(bunnei): Use proper number of elements for these
|
||||||
|
@ -570,7 +576,7 @@ private:
|
||||||
static_cast<u32>(Attribute::Index::Attribute_0)) +
|
static_cast<u32>(Attribute::Index::Attribute_0)) +
|
||||||
") out vec4 " + GetOutputAttribute(index) + ";");
|
") out vec4 " + GetOutputAttribute(index) + ";");
|
||||||
}
|
}
|
||||||
declarations.AddLine("");
|
declarations.AddNewLine();
|
||||||
|
|
||||||
unsigned const_buffer_layout = 0;
|
unsigned const_buffer_layout = 0;
|
||||||
for (const auto& entry : GetConstBuffersDeclarations()) {
|
for (const auto& entry : GetConstBuffersDeclarations()) {
|
||||||
|
@ -578,7 +584,7 @@ private:
|
||||||
declarations.AddLine('{');
|
declarations.AddLine('{');
|
||||||
declarations.AddLine(" float c" + std::to_string(entry.GetIndex()) + "[];");
|
declarations.AddLine(" float c" + std::to_string(entry.GetIndex()) + "[];");
|
||||||
declarations.AddLine("};");
|
declarations.AddLine("};");
|
||||||
declarations.AddLine("");
|
declarations.AddNewLine();
|
||||||
++const_buffer_layout;
|
++const_buffer_layout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue