diff options
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_context.h')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_context.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.h b/src/shader_recompiler/backend/glasm/emit_context.h index ae91069c8..cf66619de 100644 --- a/src/shader_recompiler/backend/glasm/emit_context.h +++ b/src/shader_recompiler/backend/glasm/emit_context.h | |||
| @@ -5,17 +5,38 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include <utility> | ||
| 9 | |||
| 10 | #include <fmt/format.h> | ||
| 8 | 11 | ||
| 9 | #include "shader_recompiler/backend/glasm/reg_alloc.h" | 12 | #include "shader_recompiler/backend/glasm/reg_alloc.h" |
| 10 | 13 | ||
| 14 | namespace Shader::IR { | ||
| 15 | class Inst; | ||
| 16 | } | ||
| 17 | |||
| 11 | namespace Shader::Backend::GLASM { | 18 | namespace Shader::Backend::GLASM { |
| 12 | 19 | ||
| 13 | class EmitContext { | 20 | class EmitContext { |
| 14 | public: | 21 | public: |
| 15 | std::string code; | 22 | explicit EmitContext(); |
| 16 | RegAlloc reg_alloc; | ||
| 17 | 23 | ||
| 18 | private: | 24 | template <typename... Args> |
| 25 | void Add(const char* fmt, IR::Inst& inst, Args&&... args) { | ||
| 26 | code += fmt::format(fmt, reg_alloc.Define(inst), std::forward<Args>(args)...); | ||
| 27 | // TODO: Remove this | ||
| 28 | code += '\n'; | ||
| 29 | } | ||
| 30 | |||
| 31 | template <typename... Args> | ||
| 32 | void Add(const char* fmt, Args&&... args) { | ||
| 33 | code += fmt::format(fmt, std::forward<Args>(args)...); | ||
| 34 | // TODO: Remove this | ||
| 35 | code += '\n'; | ||
| 36 | } | ||
| 37 | |||
| 38 | std::string code; | ||
| 39 | RegAlloc reg_alloc{*this}; | ||
| 19 | }; | 40 | }; |
| 20 | 41 | ||
| 21 | } // namespace Shader::Backend::GLASM | 42 | } // namespace Shader::Backend::GLASM |