diff options
| author | 2018-04-19 20:05:42 -0400 | |
|---|---|---|
| committer | 2018-04-19 20:09:27 -0400 | |
| commit | 412b31ad72da05c9b0e20c5c8e45354b6ff3a6b0 (patch) | |
| tree | ea7f14c48f6c053016c5552d7b0bda57d8c13da7 | |
| parent | glsl_shader_decompiler: Add char overload for ShaderWriter's AddLine() (diff) | |
| download | yuzu-412b31ad72da05c9b0e20c5c8e45354b6ff3a6b0.tar.gz yuzu-412b31ad72da05c9b0e20c5c8e45354b6ff3a6b0.tar.xz yuzu-412b31ad72da05c9b0e20c5c8e45354b6ff3a6b0.zip | |
glsl_shader_decompiler: Add AddNewLine() function to ShaderWriter
Avoids constructing a std::string just to append a newline character
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 9e60c911c..c55febbfa 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -114,13 +114,19 @@ public: | |||
| 114 | if (!text.empty()) { | 114 | if (!text.empty()) { |
| 115 | AppendIndentation(); | 115 | AppendIndentation(); |
| 116 | } | 116 | } |
| 117 | shader_source += text + '\n'; | 117 | shader_source += text; |
| 118 | AddNewLine(); | ||
| 118 | } | 119 | } |
| 119 | 120 | ||
| 120 | void AddLine(char character) { | 121 | void AddLine(char character) { |
| 121 | DEBUG_ASSERT(scope >= 0); | 122 | DEBUG_ASSERT(scope >= 0); |
| 122 | AppendIndentation(); | 123 | AppendIndentation(); |
| 123 | shader_source += character; | 124 | shader_source += character; |
| 125 | AddNewLine(); | ||
| 126 | } | ||
| 127 | |||
| 128 | void AddNewLine() { | ||
| 129 | DEBUG_ASSERT(scope >= 0); | ||
| 124 | shader_source += '\n'; | 130 | shader_source += '\n'; |
| 125 | } | 131 | } |
| 126 | 132 | ||
| @@ -475,7 +481,7 @@ private: | |||
| 475 | for (const auto& subroutine : subroutines) { | 481 | for (const auto& subroutine : subroutines) { |
| 476 | shader.AddLine("bool " + subroutine.GetName() + "();"); | 482 | shader.AddLine("bool " + subroutine.GetName() + "();"); |
| 477 | } | 483 | } |
| 478 | shader.AddLine(""); | 484 | shader.AddNewLine(); |
| 479 | 485 | ||
| 480 | // Add the main entry point | 486 | // Add the main entry point |
| 481 | shader.AddLine("bool exec_shader() {"); | 487 | shader.AddLine("bool exec_shader() {"); |
| @@ -552,7 +558,7 @@ private: | |||
| 552 | for (const auto& reg : declr_register) { | 558 | for (const auto& reg : declr_register) { |
| 553 | declarations.AddLine("float " + reg + " = 0.0;"); | 559 | declarations.AddLine("float " + reg + " = 0.0;"); |
| 554 | } | 560 | } |
| 555 | declarations.AddLine(""); | 561 | declarations.AddNewLine(); |
| 556 | 562 | ||
| 557 | for (const auto& index : declr_input_attribute) { | 563 | for (const auto& index : declr_input_attribute) { |
| 558 | // TODO(bunnei): Use proper number of elements for these | 564 | // TODO(bunnei): Use proper number of elements for these |
| @@ -561,7 +567,7 @@ private: | |||
| 561 | static_cast<u32>(Attribute::Index::Attribute_0)) + | 567 | static_cast<u32>(Attribute::Index::Attribute_0)) + |
| 562 | ") in vec4 " + GetInputAttribute(index) + ";"); | 568 | ") in vec4 " + GetInputAttribute(index) + ";"); |
| 563 | } | 569 | } |
| 564 | declarations.AddLine(""); | 570 | declarations.AddNewLine(); |
| 565 | 571 | ||
| 566 | for (const auto& index : declr_output_attribute) { | 572 | for (const auto& index : declr_output_attribute) { |
| 567 | // TODO(bunnei): Use proper number of elements for these | 573 | // TODO(bunnei): Use proper number of elements for these |
| @@ -570,7 +576,7 @@ private: | |||
| 570 | static_cast<u32>(Attribute::Index::Attribute_0)) + | 576 | static_cast<u32>(Attribute::Index::Attribute_0)) + |
| 571 | ") out vec4 " + GetOutputAttribute(index) + ";"); | 577 | ") out vec4 " + GetOutputAttribute(index) + ";"); |
| 572 | } | 578 | } |
| 573 | declarations.AddLine(""); | 579 | declarations.AddNewLine(); |
| 574 | 580 | ||
| 575 | unsigned const_buffer_layout = 0; | 581 | unsigned const_buffer_layout = 0; |
| 576 | for (const auto& entry : GetConstBuffersDeclarations()) { | 582 | for (const auto& entry : GetConstBuffersDeclarations()) { |
| @@ -578,7 +584,7 @@ private: | |||
| 578 | declarations.AddLine('{'); | 584 | declarations.AddLine('{'); |
| 579 | declarations.AddLine(" float c" + std::to_string(entry.GetIndex()) + "[];"); | 585 | declarations.AddLine(" float c" + std::to_string(entry.GetIndex()) + "[];"); |
| 580 | declarations.AddLine("};"); | 586 | declarations.AddLine("};"); |
| 581 | declarations.AddLine(""); | 587 | declarations.AddNewLine(); |
| 582 | ++const_buffer_layout; | 588 | ++const_buffer_layout; |
| 583 | } | 589 | } |
| 584 | } | 590 | } |