diff options
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_context.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.cpp b/src/shader_recompiler/backend/glasm/emit_context.cpp index f9d83dd91..66c954ff6 100644 --- a/src/shader_recompiler/backend/glasm/emit_context.cpp +++ b/src/shader_recompiler/backend/glasm/emit_context.cpp | |||
| @@ -2,10 +2,25 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <string_view> | ||
| 6 | |||
| 5 | #include "shader_recompiler/backend/glasm/emit_context.h" | 7 | #include "shader_recompiler/backend/glasm/emit_context.h" |
| 6 | #include "shader_recompiler/frontend/ir/program.h" | 8 | #include "shader_recompiler/frontend/ir/program.h" |
| 7 | 9 | ||
| 8 | namespace Shader::Backend::GLASM { | 10 | namespace Shader::Backend::GLASM { |
| 11 | namespace { | ||
| 12 | std::string_view InterpDecorator(Interpolation interp) { | ||
| 13 | switch (interp) { | ||
| 14 | case Interpolation::Smooth: | ||
| 15 | return ""; | ||
| 16 | case Interpolation::Flat: | ||
| 17 | return "FLAT "; | ||
| 18 | case Interpolation::NoPerspective: | ||
| 19 | return "NOPERSPECTIVE "; | ||
| 20 | } | ||
| 21 | throw InvalidArgument("Invalid interpolation {}", interp); | ||
| 22 | } | ||
| 23 | } // Anonymous namespace | ||
| 9 | 24 | ||
| 10 | EmitContext::EmitContext(IR::Program& program) { | 25 | EmitContext::EmitContext(IR::Program& program) { |
| 11 | // FIXME: Temporary partial implementation | 26 | // FIXME: Temporary partial implementation |
| @@ -42,6 +57,28 @@ EmitContext::EmitContext(IR::Program& program) { | |||
| 42 | stage_name = "compute"; | 57 | stage_name = "compute"; |
| 43 | break; | 58 | break; |
| 44 | } | 59 | } |
| 60 | for (size_t index = 0; index < program.info.input_generics.size(); ++index) { | ||
| 61 | const auto& generic{program.info.input_generics[index]}; | ||
| 62 | if (generic.used) { | ||
| 63 | Add("{}ATTRIB in_attr{}[]={{{}.attrib[{}..{}]}};", | ||
| 64 | InterpDecorator(generic.interpolation), index, stage_name, index, index); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | for (size_t index = 0; index < program.info.stores_frag_color.size(); ++index) { | ||
| 68 | if (!program.info.stores_frag_color[index]) { | ||
| 69 | continue; | ||
| 70 | } | ||
| 71 | if (index == 0) { | ||
| 72 | Add("OUTPUT frag_color0=result.color;"); | ||
| 73 | } else { | ||
| 74 | Add("OUTPUT frag_color{}[]=result.color[{}];", index, index); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | for (size_t index = 0; index < program.info.stores_generics.size(); ++index) { | ||
| 78 | if (program.info.stores_generics[index]) { | ||
| 79 | Add("OUTPUT out_attr{}[]={{result.attrib[{}..{}]}};", index, index, index); | ||
| 80 | } | ||
| 81 | } | ||
| 45 | } | 82 | } |
| 46 | 83 | ||
| 47 | } // namespace Shader::Backend::GLASM | 84 | } // namespace Shader::Backend::GLASM |