diff options
| author | 2021-05-30 17:27:00 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:37 -0400 | |
| commit | 1269a0cf8b3844c1a9bb06c843a7698b0a9643d5 (patch) | |
| tree | a0716589fa3952bdeb0f1d19b4bb455d9cdd86e5 /src/shader_recompiler/backend/glsl/emit_context.h | |
| parent | glsl: Fix ATOM and implement ATOMS (diff) | |
| download | yuzu-1269a0cf8b3844c1a9bb06c843a7698b0a9643d5.tar.gz yuzu-1269a0cf8b3844c1a9bb06c843a7698b0a9643d5.tar.xz yuzu-1269a0cf8b3844c1a9bb06c843a7698b0a9643d5.zip | |
glsl: Rework variable allocator to allow for variable reuse
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_context.h')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_context.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.h b/src/shader_recompiler/backend/glsl/emit_context.h index 7ae7c8766..2f1062954 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.h +++ b/src/shader_recompiler/backend/glsl/emit_context.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include <fmt/format.h> | 11 | #include <fmt/format.h> |
| 12 | 12 | ||
| 13 | #include "shader_recompiler/backend/glsl/reg_alloc.h" | 13 | #include "shader_recompiler/backend/glsl/var_alloc.h" |
| 14 | #include "shader_recompiler/stage.h" | 14 | #include "shader_recompiler/stage.h" |
| 15 | 15 | ||
| 16 | namespace Shader { | 16 | namespace Shader { |
| @@ -35,81 +35,81 @@ public: | |||
| 35 | explicit EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, | 35 | explicit EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, |
| 36 | const RuntimeInfo& runtime_info_); | 36 | const RuntimeInfo& runtime_info_); |
| 37 | 37 | ||
| 38 | template <Type type, typename... Args> | 38 | template <GlslVarType type, typename... Args> |
| 39 | void Add(const char* format_str, IR::Inst& inst, Args&&... args) { | 39 | void Add(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 40 | code += fmt::format(format_str, reg_alloc.Define(inst, type), std::forward<Args>(args)...); | 40 | code += fmt::format(format_str, var_alloc.Define(inst, type), std::forward<Args>(args)...); |
| 41 | // TODO: Remove this | 41 | // TODO: Remove this |
| 42 | code += '\n'; | 42 | code += '\n'; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | template <typename... Args> | 45 | template <typename... Args> |
| 46 | void AddU1(const char* format_str, IR::Inst& inst, Args&&... args) { | 46 | void AddU1(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 47 | Add<Type::U1>(format_str, inst, args...); | 47 | Add<GlslVarType::U1>(format_str, inst, args...); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | template <typename... Args> | 50 | template <typename... Args> |
| 51 | void AddF16x2(const char* format_str, IR::Inst& inst, Args&&... args) { | 51 | void AddF16x2(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 52 | Add<Type::F16x2>(format_str, inst, args...); | 52 | Add<GlslVarType::F16x2>(format_str, inst, args...); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | template <typename... Args> | 55 | template <typename... Args> |
| 56 | void AddU32(const char* format_str, IR::Inst& inst, Args&&... args) { | 56 | void AddU32(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 57 | Add<Type::U32>(format_str, inst, args...); | 57 | Add<GlslVarType::U32>(format_str, inst, args...); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | template <typename... Args> | 60 | template <typename... Args> |
| 61 | void AddS32(const char* format_str, IR::Inst& inst, Args&&... args) { | 61 | void AddS32(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 62 | Add<Type::S32>(format_str, inst, args...); | 62 | Add<GlslVarType::S32>(format_str, inst, args...); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | template <typename... Args> | 65 | template <typename... Args> |
| 66 | void AddF32(const char* format_str, IR::Inst& inst, Args&&... args) { | 66 | void AddF32(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 67 | Add<Type::F32>(format_str, inst, args...); | 67 | Add<GlslVarType::F32>(format_str, inst, args...); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | template <typename... Args> | 70 | template <typename... Args> |
| 71 | void AddS64(const char* format_str, IR::Inst& inst, Args&&... args) { | 71 | void AddS64(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 72 | Add<Type::S64>(format_str, inst, args...); | 72 | Add<GlslVarType::S64>(format_str, inst, args...); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | template <typename... Args> | 75 | template <typename... Args> |
| 76 | void AddU64(const char* format_str, IR::Inst& inst, Args&&... args) { | 76 | void AddU64(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 77 | Add<Type::U64>(format_str, inst, args...); | 77 | Add<GlslVarType::U64>(format_str, inst, args...); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | template <typename... Args> | 80 | template <typename... Args> |
| 81 | void AddF64(const char* format_str, IR::Inst& inst, Args&&... args) { | 81 | void AddF64(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 82 | Add<Type::F64>(format_str, inst, args...); | 82 | Add<GlslVarType::F64>(format_str, inst, args...); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | template <typename... Args> | 85 | template <typename... Args> |
| 86 | void AddU32x2(const char* format_str, IR::Inst& inst, Args&&... args) { | 86 | void AddU32x2(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 87 | Add<Type::U32x2>(format_str, inst, args...); | 87 | Add<GlslVarType::U32x2>(format_str, inst, args...); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | template <typename... Args> | 90 | template <typename... Args> |
| 91 | void AddF32x2(const char* format_str, IR::Inst& inst, Args&&... args) { | 91 | void AddF32x2(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 92 | Add<Type::F32x2>(format_str, inst, args...); | 92 | Add<GlslVarType::F32x2>(format_str, inst, args...); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | template <typename... Args> | 95 | template <typename... Args> |
| 96 | void AddU32x3(const char* format_str, IR::Inst& inst, Args&&... args) { | 96 | void AddU32x3(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 97 | Add<Type::U32x3>(format_str, inst, args...); | 97 | Add<GlslVarType::U32x3>(format_str, inst, args...); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | template <typename... Args> | 100 | template <typename... Args> |
| 101 | void AddF32x3(const char* format_str, IR::Inst& inst, Args&&... args) { | 101 | void AddF32x3(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 102 | Add<Type::F32x3>(format_str, inst, args...); | 102 | Add<GlslVarType::F32x3>(format_str, inst, args...); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | template <typename... Args> | 105 | template <typename... Args> |
| 106 | void AddU32x4(const char* format_str, IR::Inst& inst, Args&&... args) { | 106 | void AddU32x4(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 107 | Add<Type::U32x4>(format_str, inst, args...); | 107 | Add<GlslVarType::U32x4>(format_str, inst, args...); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | template <typename... Args> | 110 | template <typename... Args> |
| 111 | void AddF32x4(const char* format_str, IR::Inst& inst, Args&&... args) { | 111 | void AddF32x4(const char* format_str, IR::Inst& inst, Args&&... args) { |
| 112 | Add<Type::F32x4>(format_str, inst, args...); | 112 | Add<GlslVarType::F32x4>(format_str, inst, args...); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | template <typename... Args> | 115 | template <typename... Args> |
| @@ -121,7 +121,7 @@ public: | |||
| 121 | 121 | ||
| 122 | std::string header; | 122 | std::string header; |
| 123 | std::string code; | 123 | std::string code; |
| 124 | RegAlloc reg_alloc; | 124 | VarAlloc var_alloc; |
| 125 | const Info& info; | 125 | const Info& info; |
| 126 | const Profile& profile; | 126 | const Profile& profile; |
| 127 | const RuntimeInfo& runtime_info; | 127 | const RuntimeInfo& runtime_info; |