diff options
Diffstat (limited to 'src/shader_recompiler/backend/glasm/glasm_emit_context.h')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/glasm_emit_context.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glasm/glasm_emit_context.h b/src/shader_recompiler/backend/glasm/glasm_emit_context.h new file mode 100644 index 000000000..8433e5c00 --- /dev/null +++ b/src/shader_recompiler/backend/glasm/glasm_emit_context.h | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <string> | ||
| 8 | #include <utility> | ||
| 9 | #include <vector> | ||
| 10 | |||
| 11 | #include <fmt/format.h> | ||
| 12 | |||
| 13 | #include "shader_recompiler/backend/glasm/reg_alloc.h" | ||
| 14 | #include "shader_recompiler/stage.h" | ||
| 15 | |||
| 16 | namespace Shader { | ||
| 17 | struct Info; | ||
| 18 | struct Profile; | ||
| 19 | struct RuntimeInfo; | ||
| 20 | } // namespace Shader | ||
| 21 | |||
| 22 | namespace Shader::Backend { | ||
| 23 | struct Bindings; | ||
| 24 | } | ||
| 25 | |||
| 26 | namespace Shader::IR { | ||
| 27 | class Inst; | ||
| 28 | struct Program; | ||
| 29 | } // namespace Shader::IR | ||
| 30 | |||
| 31 | namespace Shader::Backend::GLASM { | ||
| 32 | |||
| 33 | class EmitContext { | ||
| 34 | public: | ||
| 35 | explicit EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, | ||
| 36 | const RuntimeInfo& runtime_info_); | ||
| 37 | |||
| 38 | template <typename... Args> | ||
| 39 | void Add(const char* format_str, IR::Inst& inst, Args&&... args) { | ||
| 40 | code += fmt::format(fmt::runtime(format_str), reg_alloc.Define(inst), | ||
| 41 | std::forward<Args>(args)...); | ||
| 42 | // TODO: Remove this | ||
| 43 | code += '\n'; | ||
| 44 | } | ||
| 45 | |||
| 46 | template <typename... Args> | ||
| 47 | void LongAdd(const char* format_str, IR::Inst& inst, Args&&... args) { | ||
| 48 | code += fmt::format(fmt::runtime(format_str), reg_alloc.LongDefine(inst), | ||
| 49 | std::forward<Args>(args)...); | ||
| 50 | // TODO: Remove this | ||
| 51 | code += '\n'; | ||
| 52 | } | ||
| 53 | |||
| 54 | template <typename... Args> | ||
| 55 | void Add(const char* format_str, Args&&... args) { | ||
| 56 | code += fmt::format(fmt::runtime(format_str), std::forward<Args>(args)...); | ||
| 57 | // TODO: Remove this | ||
| 58 | code += '\n'; | ||
| 59 | } | ||
| 60 | |||
| 61 | std::string code; | ||
| 62 | RegAlloc reg_alloc{}; | ||
| 63 | const Info& info; | ||
| 64 | const Profile& profile; | ||
| 65 | const RuntimeInfo& runtime_info; | ||
| 66 | |||
| 67 | std::vector<u32> texture_buffer_bindings; | ||
| 68 | std::vector<u32> image_buffer_bindings; | ||
| 69 | std::vector<u32> texture_bindings; | ||
| 70 | std::vector<u32> image_bindings; | ||
| 71 | |||
| 72 | Stage stage{}; | ||
| 73 | std::string_view stage_name = "invalid"; | ||
| 74 | std::string_view attrib_name = "invalid"; | ||
| 75 | |||
| 76 | u32 num_safety_loop_vars{}; | ||
| 77 | bool uses_y_direction{}; | ||
| 78 | }; | ||
| 79 | |||
| 80 | } // namespace Shader::Backend::GLASM | ||